#!/usr/bin/env python # -*- coding: utf-8 -*- # Viagra For Fedora Core # # Power Up Fedora with MP3, DiVX, and so. # # Copyright (c) 2006 by # # Licensed under the GNU General Public License (GPL) # # usage: # Viagra.py import sys import os import subprocess # Subprocess management # -> Stolen from vnc2swf # Will use it in next release class Subprocess: def __init__(self, s): try: import subprocess except ImportError: print >>stderr, 'Viagra requires Python 2.4 or newer.' sys.exit(111) if not hasattr(os, 'kill'): print >>stderr, 'You cannot kill! My god! Processes will leave for ever!!!' sys.exit(111) self.args = s.split(' ') self.popen = None return def start(self): import subprocess self.popen = subprocess.Popen(self.args) return def wait(self): self.popen.wait() return def stop(self): import signal os.kill(self.popen.pid, signal.SIGINT) self.popen.wait() return class PowerSystem: def AddRepositories(self, reposcode): return def ProcessOptions(self): return def destroy(self): return class FedoraCore6(PowerSystem): def SampleOption(self,packages): print "This is the simple sample option" return def YumInstallPackages(self,packages): yum=packages yum.insert(0,"install") yum.insert(0,"-yt") yum.insert(0,"yum") retcode=subprocess.call(yum) #["yum","install",packages]) #print "-->",retcode,"<--" return def YumInstallPackages2(self,packages): yumoption=packages[0] yum=packages[1:] yum.insert(0,"install") yum.insert(0,yumoption) yum.insert(0,"-yt") yum.insert(0,"yum") retcode=subprocess.call(yum) #["yum","install",packages]) return def YumCommand(self,params): yum=params yum.insert(0,"-yt") yum.insert(0,"yum") retcode=subprocess.call(yum) return def RpmInstallPackages(self,packages): rpms=packages rpms.insert(0,"-ihv") rpms.insert(0,"rpm") retcode=subprocess.call(rpms) return def SpecialTotemXine(self,params): self.YumCommand(["remove","totem"]) self.YumInstallPackages(["totem-xine"]) return options={ "MP3XB": ["MP3XB","MP3 Support For XMMS and BMP",1,"Multimedia",YumInstallPackages,["xmms","xmms-mp3","bmp-mp3","amarok-extras-nonfree"],0], "MP3AU": ["MP3AU","MP3 Support For Audacious",1,"Multimedia",YumInstallPackages,["audacious-plugins-nonfree-mp3","audacious-plugins-nonfree-wma","audacious-plugins-nonfree-aac"],0], "MP3AK": ["MP3AK","MP3 Support For Amarok",1,"Multimedia",YumInstallPackages,["amarok-extras-nonfree"],0], "TOTEMXINE": ["TOTEMXINE","Totem-Xine (DiVX)[Removes Totem]",1,"Multimedia",SpecialTotemXine,[],0], "K3BXT": ["K3BXT","K3B Extras",1,"Multimedia",YumInstallPackages,["k3b-extras-nonfree","k3b-extras"],0], "MPLAY": ["MPLAY","MPlayer ",1,"Multimedia",YumInstallPackages,["mplayer-fonts","mplayer-gui","mencoder"],0], "MPYPL": ["MPYPL","MPlayer Plugin",1,"Multimedia",YumInstallPackages,["mplayerplug-in"],0], "NTFS3G": ["NTFS3G","NTFS-3G Support",1,"System",YumInstallPackages,["ntfs-3g"],0], "YUMPLG": ["YUMPLG","Additional Yum Plugins",1,"System",YumInstallPackages,["yum-changelog","yum-allowdowngrade","yum-downloadonly","yum-skip-broken"],0], "PPTPC": ["PPTPC","PPTP Client",2,"Networking",YumInstallPackages2,["--enablerepo=pptp-stable","pptpconfig"],0], "DSKBR": ["DSKBR","Gnome Deskbar",0,"Desktop",YumInstallPackages,["deskbar-applet"],0], "NAUTLS": ["NAUTLS","Nautilus enhancements (terminal, image converter)",0,"Desktop",YumInstallPackages,["nautilus-image-converter","nautilus-open-terminal"],0], } reposneeded=0 def __init__(self): return def ProcessOptions(self): print "Working..." for optionK,option in self.options.iteritems(): #print "Option: ",option[1]," active: ",option[6] if(option[6]==1): self.reposneeded=self.reposneeded|option[2] self.AddRepositories(self.reposneeded) for optionK,option in self.options.iteritems(): if(option[6]==1): print "Doing: ",option[1] option[4](self,option[5]) return def addRepo(self,string): print "TEST:",string return def AddRepositories(self, reposcode): print "Adding repositories" if (reposcode&1): self.RpmInstallPackages(["http://rpm.livna.org/livna-release-6.rpm"]) if (reposcode&2): self.RpmInstallPackages(["http://pptpclient.sourceforge.net/yum/stable/fc6/pptp-release-current.noarch.rpm"]) #self.addRepo("livna") #if (reposcode&2): # self.addRepo("freshrpms") return def destroy(self): pass class TextInterface: def __init__(self, system): self.system=system return def ReadYN(self): a=-1 c=sys.stdin.read(1) while (a==-1): if(c=='Y'): a=1 else: a=2 c=sys.stdin.read(1) return a def DoAsking(self): print "Text Interface Selected:" for option,optionTuple in self.system.options.iteritems(): print "Option: ",optionTuple[1]," (Y/N): ", a=self.ReadYN() if(a==1): optionTuple=(optionTuple[:6]) optionTuple.append(1) self.system.options[option]=optionTuple return def main(): print "Viagra For Fedora (c) carlesm@carlesm.com " fc6=FedoraCore6() ti=TextInterface(fc6) ti.DoAsking() fc6.ProcessOptions() print "Done!!!!" main()