jlc Posted November 15, 2004 Report Share Posted November 15, 2004 (edited) With pretty much all Steve doing it, were done and you can see it on page 2 or here: FC3 how-to enable/disable repo's and script Well, I didn't post the script over there yet, i'm teasing them first to see ;-) Basically I want to create a python script that will do the following. 1. Ask for sudo or su a. /bin/su b. /usr/bin/sudo 2. Use yum a. /usr/bin/yum 3. Enable/Disable repositorys to install software. a. --disablerepo=<name> b. --eablerepo=<name> Example of how it would be used: How to I wrote to enable/disable repo's for yum and fc3 The problem is, to run it you need to type the following as an example sudo yum --enablerepo=freshrpms --enablerepo=dag --enablerepo=dries --enablerepo=newsrpms --disablerepo=livna-stable --disable=livna-testing --disablerepo=livna-unstable --disablerepo=fedora-us --disablerepo=atrpms-stable --disablerepo=atrpms-good --disablerepo=atrpms-testing --disablerepo=atrpms-bleeding install xmms-mp3 As you can see, thats a lot of typeing and things to remember! Is it doable? Any thoughts, help? I would like to use python since yum uses it. Here, I'll start #!/usr/bin/python :P Edited November 15, 2004 by cybrjackle Link to comment Share on other sites More sharing options...
jlc Posted November 15, 2004 Author Report Share Posted November 15, 2004 So far in the #musb with Ohms/LZ & fissy I've got this much out of them :D #!/usr/bin/python var = raw_input("Enable freshrpms? Y/N: ") if var is Y: fresh="--enablerepo=freshrpms" if var is N: fresh="--disablerepo=freshrpms" results = ./yumscript File "./yumscript", line 6 elif fresh="--disablerepo=freshrpms" ^ SyntaxError: invalid syntax [justin@neo python]$ ./yumscript Enable freshrpms? Y/N: Y Traceback (most recent call last): File "./yumscript", line 4, in ? if var is Y: NameError: name 'Y' is not defined Link to comment Share on other sites More sharing options...
jlc Posted November 15, 2004 Author Report Share Posted November 15, 2004 Oh and this http://docs.python.org/tut/tut.html :) Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted November 15, 2004 Report Share Posted November 15, 2004 (edited) var = raw_input("Enable freshrpms? Y/N: ") if var is "Y" or var is "y": fresh="--enablerepo=freshrpms" if var is "N" or var is "n": fresh="--disablerepo=freshrpms" Edited November 15, 2004 by Steve Scrimpshire Link to comment Share on other sites More sharing options...
jlc Posted November 15, 2004 Author Report Share Posted November 15, 2004 (edited) #!/usr/bin/python repos = {} var = raw_input("Enable freshrpms? Y/N: ") if var is "Y" or var is "y": repos["fresh"]="--enablerepo=freshrpms" if var is "N" or var is "n": repos['fresh']="--disablerepo=freshrpms" var1 = raw_input("Enable fedora-us? Y/N: ") if var1 is "Y" or var1 is "y": repos['fedora_us']="--enablerepo=fedora-us" if var1 is "N" or var1 is "n": repos['fedora_us']="--disablerepo=fedora-us" var2 = raw_input("Enable livna-stable? Y/N: ") if var2 is "Y" or var2 is "y": repos['livna_stable']="--enablerepo=livna-stable" if var2 is "N" or var2 is "n": repos['livna_stable']="--disablerepo=livna-stable" var3 = raw_input("Enable livna-testing? Y/N: ") if var3 is "Y" or var3 is "y": repos['livna_testing']="--enablerepo=livna-testing" if var3 is "N" or var3 is "n": repos['livna_testing']="--disablerepo=livna-testing" var4 = raw_input("Enable livna-unstable? Y/N: ") if var4 is "Y" or var4 is "y": repos['livna_unstable']="--enablerepo=livna-unstable" if var4 is "N" or var4 is "n": repos['livna_unstable']="--disablerepo=livna-unstable" var5 = raw_input("Enable dag? Y/N: ") if var5 is "Y" or var5 is "y": repos['dag']="--enablerepo=dag" if var5 is "N" or var5 is "n": repos['dag']="--disablerepo=dag" var6 = raw_input("Enable dries? Y/N: ") if var6 is "Y" or var6 is "y": repos['dries']="--enablerepo=dries" if var6 is "N" or var6 is "n": repos['dries']="--disablerepo=dries" var7 = raw_input("Enable newsrpms? Y/N: ") if var7 is "Y" or var7 is "y": repos['newsrpms']="--enablerepo=newsrpms" if var7 is "N" or var7 is "n": repos['newsrpms']="--disablerepo=newsrpms" var8 = raw_input("Enable atrpms-good? Y/N: ") if var8 is "Y" or var8 is "y": repos['atrpms_good']="--enablerepo=atrpms-good" if var8 is "N" or var8 is "n": repos['atrpms_good']="--disablerepo=atrpms-good" var9 = raw_input("Enable atrpms-stable? Y/N: ") if var9 is "Y" or var9 is "y": repos['atrpms_stable']="--enablerepo=atrpms-stable" if var9 is "N" or var9 is "n": repos['atrpms_stable']="--disablerepo=atrpms-stable" var10 = raw_input("Enable atrpms-testing? Y/N: ") if var10 is "Y" or var10 is "y": repos['atrpms_testing']="--enablerepo=atrpms-testing" if var10 is "N" or var10 is "n": repos['atrpms_testing']="--disablerepo=atrpms-testing" var11 = raw_input("Enable atrpms-bleeding? Y/N: ") if var11 is "Y" or var11 is "y": repos['atrpms_bleeding']="--enablerepo=atrpms-bleeding" if var11 is "N" or var11 is "n": repos['atrpms_bleeding']="--disablerepo=atrpms-bleeding" ./yumscript Enable freshrpms? Y/N: y Enable fedora-us? Y/N: y Enable livna-stable? Y/N: y Enable livna-testing? Y/N: y Enable livna-unstable? Y/N: y Enable dag? Y/N: y Enable dries? Y/N: y Enable newsrpms? Y/N: y Enable atrpms-good? Y/N: y Enable atrpms-stable? Y/N: y Enable atrpms-testing? Y/N: y Enable atrpms-bleeding? Y/N: y Edited November 15, 2004 by cybrjackle Link to comment Share on other sites More sharing options...
iphitus Posted November 15, 2004 Report Share Posted November 15, 2004 I work with python, ill give you a hand if you want, i might have a look after school today, however I have exams next week, so no promises. I might make something tonight :D Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted November 15, 2004 Report Share Posted November 15, 2004 This'll work better in the long run: var = raw_input("Enable freshrpms? Y/N: ") if var is "Y" or var is "y": repos['fresh']="--enablerepo=freshrpms" if var is "N" or var is "n": repos['fresh']="--disablerepo=freshrpms" var = raw_input("Enable dag? Y/N: ") if var is "Y" or var is "y": repos['dag']="--enablerepo=dag" if var is "N" or var is "n": repos['dag']="--disablerepo=dag" etc Link to comment Share on other sites More sharing options...
jlc Posted November 15, 2004 Author Report Share Posted November 15, 2004 bugger :D Link to comment Share on other sites More sharing options...
jlc Posted November 15, 2004 Author Report Share Posted November 15, 2004 This'll work better in the long run: var = raw_input("Enable freshrpms? Y/N: ") if var is "Y" or var is "y": repos['fresh']="--enablerepo=freshrpms" if var is "N" or var is "n": repos['fresh']="--disablerepo=freshrpms" var = raw_input("Enable dag? Y/N: ") if var is "Y" or var is "y": repos['dag']="--enablerepo=dag" if var is "N" or var is "n": repos['dag']="--disablerepo=dag" etc <{POST_SNAPBACK}> What defines repos? [justin@neo python]$ ./yumscript Enable freshrpms? Y/N: y Traceback (most recent call last): File "./yumscript", line 5, in ? repos['fresh']="--enablerepo=freshrpms" NameError: name 'repos' is not defined Link to comment Share on other sites More sharing options...
jlc Posted November 15, 2004 Author Report Share Posted November 15, 2004 I work with python, ill give you a hand if you want, i might have a look after school today, however I have exams next week, so no promises. I might make something tonight :D <{POST_SNAPBACK}> The more the better :D Link to comment Share on other sites More sharing options...
jlc Posted November 15, 2004 Author Report Share Posted November 15, 2004 Just an FYI.... I'm going to keep changeing the 5 "reply" in here as suggestions come in via #musb or here Link to comment Share on other sites More sharing options...
iphitus Posted November 15, 2004 Report Share Posted November 15, 2004 I've got it worked out, ill script something up in my next class, teacher's away, free period :P Link to comment Share on other sites More sharing options...
jlc Posted November 15, 2004 Author Report Share Posted November 15, 2004 sweet Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted November 15, 2004 Report Share Posted November 15, 2004 As you know, I'm winging this. Here's the skeleton so far with a while loop: #!/usr/bin/python import os import sys #os.system ('dvips -o out.ps "' + sys.argv[1] + '"') #os.system ('dvipdf "' + sys.argv[1] + '" out.pdf') repos={} def blah(): while True: var = raw_input("Enable freshrpms? y/n: ") if var in ('y', 'ye', 'yes'): repos["fresh"]="--enablerepo=freshrpms" return False if var in ('n', 'no', 'nop', 'nope'): repos["fresh"]="--disablerepo=freshrpms" return False blah() print repos["fresh"] Link to comment Share on other sites More sharing options...
jlc Posted November 15, 2004 Author Report Share Posted November 15, 2004 #!/usr/bin/python import os import sys import locale import time # test purposes only import yum import yum.Errors as Errors repos = {} def use_repository(): while True: var = raw_input("Enable freshrpms? y/n: ") if var in ('y', 'ye', 'yes'): repos['fresh'] = "--enablerepo=freshrpms" return False if var in ('n', 'no', 'nop', 'nope'): repos['fresh'] = "--disablerepo=freshrpms" return False use_repository() print repos["fresh"] def use_repository(): while True: var1 = raw_input("Enable fedora-us? y/n: ") if var1 in ('y', 'ye', 'yes'): return False if var1 in ('n', 'no', 'nop', 'nope'): repos['fedora-us'] = "--disablerepo=fedora-us" return False use_repository() print repos["fedora-us"] def use_repository(): while True: var2 = raw_input("Enable livna-stable? y/n: ") if var2 in ('y', 'ye', 'yes'): repos['livna-stable'] = "--enablerepo=livna-stable" return False if var2 in ('n', 'no', 'nop', 'nope'): repos['livna-stable'] = "--disablerepo=livna-stable" return False use_repository() print repos["livna-stable"] def use_repository(): while True: var3 = raw_input("Enable livna-testing? y/n: ") if var3 in ('y', 'ye', 'yes'): repos['livna-testing'] = "--enablerepo=livna-testing" return False use_repository() print repos["livna-testing"] def use_repository(): while True: var4 = raw_input("Enable livna-unstable? y/n: ") if var4 in ('y', 'ye', 'yes'): repos['livna-unstable'] = "--enablerepo=livna-unstable" return False if var4 in ('n', 'no', 'nop', 'nope'): repos['livna-unstable'] = "--disablerepo=livna-unstable" return False use_repository() print repos["livna-unstable"] def use_repository(): while True: var5 = raw_input("Enable dag? y/n: ") if var5 in ('y', 'ye', 'yes'): repos['dag'] = "--enablerepo=dag" return False if var5 in ('n', 'no', 'nop', 'nope'): repos['dag'] = "--disablerepo=dag" return False use_repository() print repos["dag"] def use_repository(): while True: var6 = raw_input("Enable dries? y/n: ") if var6 in ('y', 'ye', 'yes'): repos['dries'] = "--enablerepo=dries" return False if var6 in ('n', 'no', 'nop', 'nope'): repos['dries'] = "--disablerepo=dries" return False use_repository() print repos["dries"] def use_repository(): while True: var7 = raw_input("Enable newsrpms? y/n: ") if var7 in ('y', 'ye', 'yes'): repos['newsrpms'] = "--enablerepo=newsrpms" return False if var7 in ('n', 'no', 'nop', 'nope'): repos['newsrpms'] = "--disablerepo=newsrpms" return False use_repository() print repos["newsrpms"] def use_repository(): while True: var8 = raw_input("Enable atrpms-good? y/n: ") if var8 in ('y', 'ye', 'yes'): repos['atrpms-good'] = "--enablerepo=atrpms-good" return False if var8 in ('n', 'no', 'nop', 'nope'): repos['atrpms-good'] = "--disablerepo=atrpms-good" return False use_repository() print repos["atrpms-good"] def use_repository(): while True: var9 = raw_input("Enable atrpms-stable? y/n: ") if var9 in ('y', 'ye', 'yes'): repos['atrpms-stable'] = "--enablerepo=atrpms-stable" return False if var9 in ('n', 'no', 'nop', 'nope'): repos['atrpms-stable'] = "--disablerepo=atrpms-stable" return False use_repository() print repos["atrpms-stable"] def use_repository(): while True: var10 = raw_input("Enable atrpms-testing? y/n: ") if var10 in ('y', 'ye', 'yes'): repos['atrpms-testing'] = "--enablerepo=atrpms-testing" return False if var10 in ('n', 'no', 'nop', 'nope'): repos['atrpms-testing'] = "--disablerepo=atrpms-testing" return False use_repository() print repos["atrpms-testing"] def use_repository(): while True: var11 = raw_input("Enable atrpms-bleeding? y/n: ") if var11 in ('y', 'ye', 'yes'): repos['atrpms-bleeding'] = "--enablerepo=atrpms-bleeding" return False if var11 in ('n', 'no', 'nop', 'nope'): repos['atrpms-bleeding'] = "--disablerepo=atrpms-bleeding" return False use_repository() print repos["atrpms-bleeding"] $ ./yumscript Enable freshrpms? y/n: y --enablerepo=freshrpms Enable fedora-us? y/n: n --disablerepo=fedora-us Enable livna-stable? y/n: n --disablerepo=livna-stable Enable livna-testing? y/n: y --enablerepo=livna-testing Enable livna-unstable? y/n: n --disablerepo=livna-unstable Enable dag? y/n: n --disablerepo=dag Enable dries? y/n: y --enablerepo=dries Enable newsrpms? y/n: n --disablerepo=newsrpms Enable atrpms-good? y/n: y --enablerepo=atrpms-good Enable atrpms-stable? y/n: n --disablerepo=atrpms-stable Enable atrpms-testing? y/n: y --enablerepo=atrpms-testing Enable atrpms-bleeding? y/n: n --disablerepo=atrpms-bleeding That was a lot of typing :o Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now