51
51
from datetime import timedelta
52
52
from datetime import timezone
53
53
54
- try :
55
- import holidays
56
- import yaml
57
- from ics import Calendar , Event
58
- from jinja2 import Environment
59
- except :
60
- print ("You lack some of the module dependencies to run this script." )
61
- print ("Please run 'pip3 install -r requirements.txt' and try again." )
62
- sys .exit (1 )
54
+ import holidays
55
+ import yaml
56
+ from ics import Calendar , Event
57
+ from jinja2 import Environment
63
58
64
59
import scriptutil
65
60
from consolemenu import ConsoleMenu
@@ -173,26 +168,26 @@ def check_prerequisites(todo=None):
173
168
sys .exit ("Script requires Python v3.4 or later" )
174
169
try :
175
170
gpg_ver = run ("gpg --version" ).splitlines ()[0 ]
176
- except :
171
+ except Exception :
177
172
sys .exit ("You will need gpg installed" )
178
- if not 'GPG_TTY' in os .environ :
173
+ if 'GPG_TTY' not in os .environ :
179
174
print ("WARNING: GPG_TTY environment variable is not set, GPG signing may not work correctly (try 'export GPG_TTY=$(tty)'" )
180
- if not 'JAVA11_HOME' in os .environ :
175
+ if 'JAVA11_HOME' not in os .environ :
181
176
sys .exit ("Please set environment variables JAVA11_HOME" )
182
177
try :
183
178
asciidoc_ver = run ("asciidoctor -V" ).splitlines ()[0 ]
184
- except :
179
+ except Exception :
185
180
asciidoc_ver = ""
186
181
print ("WARNING: In order to export asciidoc version to HTML, you will need asciidoctor installed" )
187
182
try :
188
183
git_ver = run ("git --version" ).splitlines ()[0 ]
189
- except :
184
+ except Exception :
190
185
sys .exit ("You will need git installed" )
191
186
try :
192
187
run ("svn --version" ).splitlines ()[0 ]
193
- except :
188
+ except Exception :
194
189
sys .exit ("You will need svn installed" )
195
- if not 'EDITOR' in os .environ :
190
+ if 'EDITOR' not in os .environ :
196
191
print ("WARNING: Environment variable $EDITOR not set, using %s" % get_editor ())
197
192
198
193
if todo :
@@ -285,7 +280,7 @@ def __init__(self, config_path, release_version, script_version):
285
280
self .mirrored_versions = None
286
281
try :
287
282
self .script_branch_type = scriptutil .find_branch_type ()
288
- except :
283
+ except Exception :
289
284
print ("WARNING: This script shold (ideally) run from the release branch, not a feature branch (%s)" % self .script_branch )
290
285
self .script_branch_type = 'feature'
291
286
self .set_release_version (release_version )
@@ -510,7 +505,7 @@ def get_rc_number(self):
510
505
def get_current_git_rev (self ):
511
506
try :
512
507
return run ("git rev-parse HEAD" , cwd = self .get_git_checkout_folder ()).strip ()
513
- except :
508
+ except Exception :
514
509
return "<git-rev>"
515
510
516
511
def get_group_by_id (self , id ):
@@ -717,7 +712,7 @@ def __init__(self, id, title, description=None, post_description=None, done=None
717
712
if self .types :
718
713
self .types = ensure_list (self .types )
719
714
for t in self .types :
720
- if not t in ['minor' , 'major' , 'bugfix' ]:
715
+ if t not in ['minor' , 'major' , 'bugfix' ]:
721
716
sys .exit ("Wrong Todo config for '%s'. Type needs to be either 'minor', 'major' or 'bugfix'" % self .id )
722
717
if commands :
723
718
self .commands .todo_id = self .id
@@ -867,7 +862,7 @@ def get_release_version():
867
862
v = str (input ("Which version are you releasing? (x.y.z) " ))
868
863
try :
869
864
version = Version .parse (v )
870
- except :
865
+ except Exception :
871
866
print ("Not a valid version %s" % v )
872
867
return get_release_version ()
873
868
@@ -1011,8 +1006,8 @@ def generate_asciidoc():
1011
1006
fh .write ("\n %s\n \n " % todo .get_post_description ())
1012
1007
if todo .links :
1013
1008
fh .write ("Links:\n \n " )
1014
- for l in todo .links :
1015
- fh .write ("* %s\n " % expand_jinja (l ))
1009
+ for link in todo .links :
1010
+ fh .write ("* %s\n " % expand_jinja (link ))
1016
1011
fh .write ("\n " )
1017
1012
1018
1013
fh .close ()
@@ -1031,7 +1026,7 @@ def load_rc():
1031
1026
try :
1032
1027
with open (lucenerc , 'r' ) as fp :
1033
1028
return json .load (fp )
1034
- except :
1029
+ except Exception :
1035
1030
return None
1036
1031
1037
1032
@@ -1160,7 +1155,7 @@ def configure_pgp(gpg_todo):
1160
1155
print ("Please either generate a strong key or reconfigure your client" )
1161
1156
return False
1162
1157
print ("Validated that your key is of type RSA and has a length >= 2048 (%s)" % length )
1163
- except :
1158
+ except Exception :
1164
1159
print (textwrap .dedent ("""\
1165
1160
Key not found on your private gpg keychain. In order to sign the release you'll
1166
1161
need to fix this, then try again""" ))
@@ -1170,14 +1165,14 @@ def configure_pgp(gpg_todo):
1170
1165
sigs = 0
1171
1166
apache_sigs = 0
1172
1167
for line in lines :
1173
- if line .startswith ("sig" ) and not gpg_id in line :
1168
+ if line .startswith ("sig" ) and gpg_id not in line :
1174
1169
sigs += 1
1175
1170
if '@apache.org' in line :
1176
1171
apache_sigs += 1
1177
1172
print ("Your key has %s signatures, of which %s are by committers (@apache.org address)" % (sigs , apache_sigs ))
1178
1173
if apache_sigs < 1 :
1179
1174
print (textwrap .dedent ("""\
1180
- Your key is not signed by any other committer.
1175
+ Your key is not signed by any other committer.
1181
1176
Please review https://infra.apache.org/openpgp.html#apache-wot
1182
1177
and make sure to get your key signed until next time.
1183
1178
You may want to run 'gpg --refresh-keys' to refresh your keychain.""" ))
@@ -1220,7 +1215,7 @@ def configure_pgp(gpg_todo):
1220
1215
print (textwrap .dedent ("""\
1221
1216
You need the passphrase to sign the release.
1222
1217
This script can prompt you securely for your passphrase (will not be stored) and pass it on to
1223
- buildAndPushRelease in a secure way. However, you can also configure your passphrase in advance
1218
+ buildAndPushRelease in a secure way. However, you can also configure your passphrase in advance
1224
1219
and avoid having to type it in the terminal. This can be done with either a gpg-agent (for gpg tool)
1225
1220
or in gradle.properties or an ENV.var (for gradle), See ./gradlew helpPublishing for details.""" ))
1226
1221
gpg_state ['prompt_pass' ] = ask_yes_no ("Do you want this wizard to prompt you for your gpg password? " )
@@ -1251,7 +1246,7 @@ def main():
1251
1246
1252
1247
try :
1253
1248
ConsoleMenu (clear_screen = True )
1254
- except Exception as e :
1249
+ except Exception :
1255
1250
sys .exit ("You need to install 'consolemenu' package version 0.7.1 for the Wizard to function. Please run 'pip "
1256
1251
"install -r requirements.txt'" )
1257
1252
@@ -1264,7 +1259,6 @@ def main():
1264
1259
release_root = os .path .expanduser ("~/.lucene-releases" )
1265
1260
if not load_rc () or c .init :
1266
1261
print ("Initializing" )
1267
- dir_ok = False
1268
1262
root = str (input ("Choose root folder: [~/.lucene-releases] " ))
1269
1263
if os .path .exists (root ) and (not os .path .isdir (root ) or not os .access (root , os .W_OK )):
1270
1264
sys .exit ("Root %s exists but is not a directory or is not writable" % root )
@@ -1552,8 +1546,8 @@ def run(self): # pylint: disable=inconsistent-return-statements # TODO
1552
1546
for line in cmd .display_cmd ():
1553
1547
print (" %s" % line )
1554
1548
print ()
1555
- confirm_each = (not self .confirm_each_command is False ) and len (commands ) > 1
1556
- if not self .enable_execute is False :
1549
+ confirm_each = (self .confirm_each_command is not False ) and len (commands ) > 1
1550
+ if self .enable_execute is not False :
1557
1551
if self .run_text :
1558
1552
print ("\n %s\n " % self .get_run_text ())
1559
1553
if confirm_each :
@@ -1825,7 +1819,7 @@ def run(self, dict=None):
1825
1819
return result
1826
1820
1827
1821
1828
- def create_ical (todo ): # pylint: disable=unused-argument
1822
+ def create_ical (_todo ): # pylint: disable=unused-argument
1829
1823
if ask_yes_no ("Do you want to add a Calendar reminder for the close vote time?" ):
1830
1824
c = Calendar ()
1831
1825
e = Event ()
@@ -1872,7 +1866,7 @@ def vote_close_72h_holidays():
1872
1866
return holidays if len (holidays ) > 0 else None
1873
1867
1874
1868
1875
- def prepare_announce_lucene (todo ): # pylint: disable=unused-argument
1869
+ def prepare_announce_lucene (_todo ): # pylint: disable=unused-argument
1876
1870
if not os .path .exists (lucene_news_file ):
1877
1871
lucene_text = expand_jinja ("(( template=announce_lucene ))" )
1878
1872
with open (lucene_news_file , 'w' ) as fp :
@@ -1883,7 +1877,7 @@ def prepare_announce_lucene(todo): # pylint: disable=unused-argument
1883
1877
return True
1884
1878
1885
1879
1886
- def check_artifacts_available (todo ): # pylint: disable=unused-argument
1880
+ def check_artifacts_available (_todo ): # pylint: disable=unused-argument
1887
1881
try :
1888
1882
cdnUrl = expand_jinja ("https://dlcdn.apache.org/lucene/java/{{ release_version }}/lucene-{{ release_version }}-src.tgz.asc" )
1889
1883
load (cdnUrl )
0 commit comments