Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Cc: Brian Dolbec <dolsen@g.o>
Subject: [gentoo-catalyst] [PATCH 4/4] cleanup long lines, improve usage() output formatting slightly
Date: Sat, 14 Dec 2013 03:07:56
Message-Id: 1386990436-9198-5-git-send-email-dolsen@gentoo.org
In Reply to: [gentoo-catalyst] rewrite-on-master patches by Brian Dolbec
1 ---
2 catalyst | 83 +++++++++++++++++++++++++++++++++++++---------------------------
3 1 file changed, 48 insertions(+), 35 deletions(-)
4
5 diff --git a/catalyst b/catalyst
6 index 60cea3e..a68a2ba 100755
7 --- a/catalyst
8 +++ b/catalyst
9 @@ -24,31 +24,33 @@ __version__="2.0.15"
10 conf_values={}
11
12 def usage():
13 - print "Usage catalyst [options] [-C variable=value...] [ -s identifier]"
14 - print " -a --clear-autoresume clear autoresume flags"
15 - print " -c --config use specified configuration file"
16 - print " -C --cli catalyst commandline (MUST BE LAST OPTION)"
17 - print " -d --debug enable debugging"
18 - print " -f --file read specfile"
19 - print " -F --fetchonly fetch files only"
20 - print " -h --help print this help message"
21 - print " -p --purge clear tmp dirs,package cache and autoresume flags"
22 - print " -P --purgeonly clear tmp dirs,package cache and autoresume flags and exit"
23 - print " -T --purgetmponly clear tmp dirs and autoresume flags and exit"
24 - print " -s --snapshot generate a release snapshot"
25 - print " -V --version display version information"
26 - print " -v --verbose verbose output"
27 - print
28 - print "Usage examples:"
29 - print
30 - print "Using the commandline option (-C, --cli) to build a Portage snapshot:"
31 - print "catalyst -C target=snapshot version_stamp=my_date"
32 - print
33 - print "Using the snapshot option (-s, --snapshot) to build a release snapshot:"
34 - print "catalyst -s 20071121"
35 - print
36 - print "Using the specfile option (-f, --file) to build a stage target:"
37 - print "catalyst -f stage1-specfile.spec"
38 + print """Usage catalyst [options] [-C variable=value...] [ -s identifier]
39 + -a --clear-autoresume clear autoresume flags
40 + -c --config use specified configuration file
41 + -C --cli catalyst commandline (MUST BE LAST OPTION)
42 + -d --debug enable debugging
43 + -f --file read specfile
44 + -F --fetchonly fetch files only
45 + -h --help print this help message
46 + -p --purge clear tmp dirs,package cache, autoresume flags
47 + -P --purgeonly clear tmp dirs,package cache, autoresume flags and exit
48 + -T --purgetmponly clear tmp dirs and autoresume flags and exit
49 + -s --snapshot generate a release snapshot
50 + -V --version display version information
51 + -v --verbose verbose output
52 +
53 +Usage examples:
54 +
55 +Using the commandline option (-C, --cli) to build a Portage snapshot:
56 +catalyst -C target=snapshot version_stamp=my_date
57 +
58 +Using the snapshot option (-s, --snapshot) to build a release snapshot:
59 +catalyst -s 20071121"
60 +
61 +Using the specfile option (-f, --file) to build a stage target:
62 +catalyst -f stage1-specfile.spec
63 +"""
64 +
65
66 def version():
67 print "Catalyst, version "+__version__
68 @@ -77,7 +79,8 @@ def parse_config(myconfig):
69 # first, try the one passed (presumably from the cmdline)
70 if myconfig:
71 if os.path.exists(myconfig):
72 - print "Using command line specified Catalyst configuration file, "+myconfig
73 + print "Using command line specified Catalyst configuration file, "+\
74 + myconfig
75 config_file=myconfig
76
77 else:
78 @@ -87,7 +90,8 @@ def parse_config(myconfig):
79
80 # next, try the default location
81 elif os.path.exists("/etc/catalyst/catalyst.conf"):
82 - print "Using default Catalyst configuration file, /etc/catalyst/catalyst.conf"
83 + print "Using default Catalyst configuration file," + \
84 + " /etc/catalyst/catalyst.conf"
85 config_file="/etc/catalyst/catalyst.conf"
86
87 # can't find a config file (we are screwed), so bail out
88 @@ -183,14 +187,16 @@ def parse_config(myconfig):
89 conf_values["port_logdir"]=myconf["port_logdir"];
90
91 def import_modules():
92 - # import catalyst's own modules (i.e. catalyst_support and the arch modules)
93 + # import catalyst's own modules
94 + # (i.e. catalyst_support and the arch modules)
95 targetmap={}
96
97 try:
98 for x in required_build_targets:
99 try:
100 fh=open(conf_values["sharedir"]+"/modules/"+x+".py")
101 - module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
102 + module=imp.load_module(x,fh,"modules/"+x+".py",
103 + (".py","r",imp.PY_SOURCE))
104 fh.close()
105
106 except IOError:
107 @@ -200,7 +206,8 @@ def import_modules():
108 for x in valid_build_targets:
109 try:
110 fh=open(conf_values["sharedir"]+"/modules/"+x+".py")
111 - module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
112 + module=imp.load_module(x,fh,"modules/"+x+".py",
113 + (".py","r",imp.PY_SOURCE))
114 module.register(targetmap)
115 fh.close()
116
117 @@ -218,15 +225,17 @@ def import_modules():
118 def build_target(addlargs, targetmap):
119 try:
120 if addlargs["target"] not in targetmap:
121 - raise CatalystError,"Target \""+addlargs["target"]+"\" not available."
122 + raise CatalystError, \
123 + "Target \"%s\" not available." % addlargs["target"]
124
125 mytarget=targetmap[addlargs["target"]](conf_values, addlargs)
126
127 mytarget.run()
128
129 except:
130 - modules.catalyst.util.print_traceback()
131 - print "!!! catalyst: Error encountered during run of target " + addlargs["target"]
132 + catalyst.util.print_traceback()
133 + print "!!! catalyst: Error encountered during run of target " + \
134 + addlargs["target"]
135 sys.exit(1)
136
137 if __name__ == "__main__":
138 @@ -245,8 +254,12 @@ if __name__ == "__main__":
139
140 # parse out the command line arguments
141 try:
142 - opts,args = getopt.getopt(sys.argv[1:], "apPThvdc:C:f:FVs:", ["purge", "purgeonly", "purgetmponly", "help", "version", "debug",\
143 - "clear-autoresume", "config=", "cli=", "file=", "fetch", "verbose","snapshot="])
144 + opts,args = getopt.getopt(sys.argv[1:], "apPThvdc:C:f:FVs:",
145 + ["purge", "purgeonly", "purgetmponly", "help", "version", "debug",
146 + "clear-autoresume", "config=", "cli=", "file=", "fetch",
147 + "verbose","snapshot="
148 + ]
149 + )
150
151 except getopt.GetoptError:
152 usage()
153 --
154 1.8.3.2

Replies