mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Use sys.exit(...) instead of exit(...): exit(...) should not be used in programs
This commit is contained in:
parent
f088a1bb39
commit
25cd520fc4
@ -12,6 +12,7 @@ Author: @MarcoFalke
|
|||||||
|
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
FOLDER_GREP = 'src'
|
FOLDER_GREP = 'src'
|
||||||
FOLDER_TEST = 'src/test/'
|
FOLDER_TEST = 'src/test/'
|
||||||
@ -39,7 +40,7 @@ def main():
|
|||||||
print "Args unknown : %s" % len(args_unknown)
|
print "Args unknown : %s" % len(args_unknown)
|
||||||
print args_unknown
|
print args_unknown
|
||||||
|
|
||||||
exit(len(args_need_doc))
|
sys.exit(len(args_need_doc))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -20,6 +20,7 @@ from sys import stdin,stdout,stderr
|
|||||||
import argparse
|
import argparse
|
||||||
import hashlib
|
import hashlib
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import json,codecs
|
import json,codecs
|
||||||
try:
|
try:
|
||||||
from urllib.request import Request,urlopen
|
from urllib.request import Request,urlopen
|
||||||
@ -158,11 +159,11 @@ def main():
|
|||||||
if repo is None:
|
if repo is None:
|
||||||
print("ERROR: No repository configured. Use this command to set:", file=stderr)
|
print("ERROR: No repository configured. Use this command to set:", file=stderr)
|
||||||
print("git config githubmerge.repository <owner>/<repo>", file=stderr)
|
print("git config githubmerge.repository <owner>/<repo>", file=stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
if signingkey is None:
|
if signingkey is None:
|
||||||
print("ERROR: No GPG signing key set. Set one using:",file=stderr)
|
print("ERROR: No GPG signing key set. Set one using:",file=stderr)
|
||||||
print("git config --global user.signingkey <key>",file=stderr)
|
print("git config --global user.signingkey <key>",file=stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
host_repo = host+":"+repo # shortcut for push/pull target
|
host_repo = host+":"+repo # shortcut for push/pull target
|
||||||
|
|
||||||
@ -173,7 +174,7 @@ def main():
|
|||||||
# Receive pull information from github
|
# Receive pull information from github
|
||||||
info = retrieve_pr_info(repo,pull)
|
info = retrieve_pr_info(repo,pull)
|
||||||
if info is None:
|
if info is None:
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
title = info['title'].strip()
|
title = info['title'].strip()
|
||||||
body = info['body'].strip()
|
body = info['body'].strip()
|
||||||
# precedence order for destination branch argument:
|
# precedence order for destination branch argument:
|
||||||
@ -194,27 +195,27 @@ def main():
|
|||||||
subprocess.check_call([GIT,'checkout','-q',branch])
|
subprocess.check_call([GIT,'checkout','-q',branch])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot check out branch %s." % (branch), file=stderr)
|
print("ERROR: Cannot check out branch %s." % (branch), file=stderr)
|
||||||
exit(3)
|
sys.exit(3)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/pull/'+pull+'/*:refs/heads/pull/'+pull+'/*'])
|
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/pull/'+pull+'/*:refs/heads/pull/'+pull+'/*'])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot find pull request #%s on %s." % (pull,host_repo), file=stderr)
|
print("ERROR: Cannot find pull request #%s on %s." % (pull,host_repo), file=stderr)
|
||||||
exit(3)
|
sys.exit(3)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+head_branch], stdout=devnull, stderr=stdout)
|
subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+head_branch], stdout=devnull, stderr=stdout)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot find head of pull request #%s on %s." % (pull,host_repo), file=stderr)
|
print("ERROR: Cannot find head of pull request #%s on %s." % (pull,host_repo), file=stderr)
|
||||||
exit(3)
|
sys.exit(3)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+merge_branch], stdout=devnull, stderr=stdout)
|
subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+merge_branch], stdout=devnull, stderr=stdout)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot find merge of pull request #%s on %s." % (pull,host_repo), file=stderr)
|
print("ERROR: Cannot find merge of pull request #%s on %s." % (pull,host_repo), file=stderr)
|
||||||
exit(3)
|
sys.exit(3)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/heads/'+branch+':refs/heads/'+base_branch])
|
subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/heads/'+branch+':refs/heads/'+base_branch])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot find branch %s on %s." % (branch,host_repo), file=stderr)
|
print("ERROR: Cannot find branch %s on %s." % (branch,host_repo), file=stderr)
|
||||||
exit(3)
|
sys.exit(3)
|
||||||
subprocess.check_call([GIT,'checkout','-q',base_branch])
|
subprocess.check_call([GIT,'checkout','-q',base_branch])
|
||||||
subprocess.call([GIT,'branch','-q','-D',local_merge_branch], stderr=devnull)
|
subprocess.call([GIT,'branch','-q','-D',local_merge_branch], stderr=devnull)
|
||||||
subprocess.check_call([GIT,'checkout','-q','-b',local_merge_branch])
|
subprocess.check_call([GIT,'checkout','-q','-b',local_merge_branch])
|
||||||
@ -236,17 +237,17 @@ def main():
|
|||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print("ERROR: Cannot be merged cleanly.",file=stderr)
|
print("ERROR: Cannot be merged cleanly.",file=stderr)
|
||||||
subprocess.check_call([GIT,'merge','--abort'])
|
subprocess.check_call([GIT,'merge','--abort'])
|
||||||
exit(4)
|
sys.exit(4)
|
||||||
logmsg = subprocess.check_output([GIT,'log','--pretty=format:%s','-n','1']).decode('utf-8')
|
logmsg = subprocess.check_output([GIT,'log','--pretty=format:%s','-n','1']).decode('utf-8')
|
||||||
if logmsg.rstrip() != firstline.rstrip():
|
if logmsg.rstrip() != firstline.rstrip():
|
||||||
print("ERROR: Creating merge failed (already merged?).",file=stderr)
|
print("ERROR: Creating merge failed (already merged?).",file=stderr)
|
||||||
exit(4)
|
sys.exit(4)
|
||||||
|
|
||||||
symlink_files = get_symlink_files()
|
symlink_files = get_symlink_files()
|
||||||
for f in symlink_files:
|
for f in symlink_files:
|
||||||
print("ERROR: File %s was a symlink" % f)
|
print("ERROR: File %s was a symlink" % f)
|
||||||
if len(symlink_files) > 0:
|
if len(symlink_files) > 0:
|
||||||
exit(4)
|
sys.exit(4)
|
||||||
|
|
||||||
# Put tree SHA512 into the message
|
# Put tree SHA512 into the message
|
||||||
try:
|
try:
|
||||||
@ -254,12 +255,12 @@ def main():
|
|||||||
message += '\n\nTree-SHA512: ' + first_sha512
|
message += '\n\nTree-SHA512: ' + first_sha512
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
printf("ERROR: Unable to compute tree hash")
|
printf("ERROR: Unable to compute tree hash")
|
||||||
exit(4)
|
sys.exit(4)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([GIT,'commit','--amend','-m',message.encode('utf-8')])
|
subprocess.check_call([GIT,'commit','--amend','-m',message.encode('utf-8')])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
printf("ERROR: Cannot update message.",file=stderr)
|
printf("ERROR: Cannot update message.",file=stderr)
|
||||||
exit(4)
|
sys.exit(4)
|
||||||
|
|
||||||
print_merge_details(pull, title, branch, base_branch, head_branch)
|
print_merge_details(pull, title, branch, base_branch, head_branch)
|
||||||
print()
|
print()
|
||||||
@ -268,7 +269,7 @@ def main():
|
|||||||
if testcmd:
|
if testcmd:
|
||||||
if subprocess.call(testcmd,shell=True):
|
if subprocess.call(testcmd,shell=True):
|
||||||
print("ERROR: Running %s failed." % testcmd,file=stderr)
|
print("ERROR: Running %s failed." % testcmd,file=stderr)
|
||||||
exit(5)
|
sys.exit(5)
|
||||||
|
|
||||||
# Show the created merge.
|
# Show the created merge.
|
||||||
diff = subprocess.check_output([GIT,'diff',merge_branch+'..'+local_merge_branch])
|
diff = subprocess.check_output([GIT,'diff',merge_branch+'..'+local_merge_branch])
|
||||||
@ -279,7 +280,7 @@ def main():
|
|||||||
if reply.lower() == 'ignore':
|
if reply.lower() == 'ignore':
|
||||||
print("Difference with github ignored.",file=stderr)
|
print("Difference with github ignored.",file=stderr)
|
||||||
else:
|
else:
|
||||||
exit(6)
|
sys.exit(6)
|
||||||
else:
|
else:
|
||||||
# Verify the result manually.
|
# Verify the result manually.
|
||||||
print("Dropping you on a shell so you can try building/testing the merged source.",file=stderr)
|
print("Dropping you on a shell so you can try building/testing the merged source.",file=stderr)
|
||||||
@ -292,7 +293,7 @@ def main():
|
|||||||
second_sha512 = tree_sha512sum()
|
second_sha512 = tree_sha512sum()
|
||||||
if first_sha512 != second_sha512:
|
if first_sha512 != second_sha512:
|
||||||
print("ERROR: Tree hash changed unexpectedly",file=stderr)
|
print("ERROR: Tree hash changed unexpectedly",file=stderr)
|
||||||
exit(8)
|
sys.exit(8)
|
||||||
|
|
||||||
# Sign the merge commit.
|
# Sign the merge commit.
|
||||||
print_merge_details(pull, title, branch, base_branch, head_branch)
|
print_merge_details(pull, title, branch, base_branch, head_branch)
|
||||||
@ -306,7 +307,7 @@ def main():
|
|||||||
print("Error while signing, asking again.",file=stderr)
|
print("Error while signing, asking again.",file=stderr)
|
||||||
elif reply == 'x':
|
elif reply == 'x':
|
||||||
print("Not signing off on merge, exiting.",file=stderr)
|
print("Not signing off on merge, exiting.",file=stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Put the result in branch.
|
# Put the result in branch.
|
||||||
subprocess.check_call([GIT,'checkout','-q',branch])
|
subprocess.check_call([GIT,'checkout','-q',branch])
|
||||||
@ -326,7 +327,7 @@ def main():
|
|||||||
subprocess.check_call([GIT,'push',host_repo,'refs/heads/'+branch])
|
subprocess.check_call([GIT,'push',host_repo,'refs/heads/'+branch])
|
||||||
break
|
break
|
||||||
elif reply == 'x':
|
elif reply == 'x':
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -212,5 +212,5 @@ if __name__ == '__main__':
|
|||||||
except IOError:
|
except IOError:
|
||||||
print('%s: cannot open' % filename)
|
print('%s: cannot open' % filename)
|
||||||
retval = 1
|
retval = 1
|
||||||
exit(retval)
|
sys.exit(retval)
|
||||||
|
|
||||||
|
@ -159,6 +159,6 @@ if __name__ == '__main__':
|
|||||||
print('%s: NEEDED library %s is not allowed' % (filename, library_name.decode('utf-8')))
|
print('%s: NEEDED library %s is not allowed' % (filename, library_name.decode('utf-8')))
|
||||||
retval = 1
|
retval = 1
|
||||||
|
|
||||||
exit(retval)
|
sys.exit(retval)
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,12 +36,12 @@ def check_at_repository_root():
|
|||||||
if not os.path.exists('.git'):
|
if not os.path.exists('.git'):
|
||||||
print('No .git directory found')
|
print('No .git directory found')
|
||||||
print('Execute this script at the root of the repository', file=sys.stderr)
|
print('Execute this script at the root of the repository', file=sys.stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def fetch_all_translations():
|
def fetch_all_translations():
|
||||||
if subprocess.call([TX, 'pull', '-f', '-a']):
|
if subprocess.call([TX, 'pull', '-f', '-a']):
|
||||||
print('Error while fetching translations', file=sys.stderr)
|
print('Error while fetching translations', file=sys.stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def find_format_specifiers(s):
|
def find_format_specifiers(s):
|
||||||
'''Find all format specifiers in a string.'''
|
'''Find all format specifiers in a string.'''
|
||||||
|
@ -87,7 +87,7 @@ def get_block_hashes(settings, max_blocks_per_call=10000):
|
|||||||
for x,resp_obj in enumerate(reply):
|
for x,resp_obj in enumerate(reply):
|
||||||
if rpc.response_is_error(resp_obj):
|
if rpc.response_is_error(resp_obj):
|
||||||
print('JSON-RPC: error at height', height+x, ': ', resp_obj['error'], file=sys.stderr)
|
print('JSON-RPC: error at height', height+x, ': ', resp_obj['error'], file=sys.stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
assert(resp_obj['id'] == x) # assume replies are in-sequence
|
assert(resp_obj['id'] == x) # assume replies are in-sequence
|
||||||
if settings['rev_hash_bytes'] == 'true':
|
if settings['rev_hash_bytes'] == 'true':
|
||||||
resp_obj['result'] = hex_switchEndian(resp_obj['result'])
|
resp_obj['result'] = hex_switchEndian(resp_obj['result'])
|
||||||
|
@ -114,7 +114,7 @@ def process_nodes(g, f, structname, defaultport):
|
|||||||
def main():
|
def main():
|
||||||
if len(sys.argv)<2:
|
if len(sys.argv)<2:
|
||||||
print(('Usage: %s <path_to_nodes_txt>' % sys.argv[0]), file=sys.stderr)
|
print(('Usage: %s <path_to_nodes_txt>' % sys.argv[0]), file=sys.stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
g = sys.stdout
|
g = sys.stdout
|
||||||
indir = sys.argv[1]
|
indir = sys.argv[1]
|
||||||
g.write('#ifndef BITCOIN_CHAINPARAMSSEEDS_H\n')
|
g.write('#ifndef BITCOIN_CHAINPARAMSSEEDS_H\n')
|
||||||
|
@ -32,7 +32,7 @@ import sys
|
|||||||
|
|
||||||
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 5):
|
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 5):
|
||||||
print("This example only works with Python 3.5 and greater")
|
print("This example only works with Python 3.5 and greater")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
port = 28332
|
port = 28332
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import sys
|
|||||||
|
|
||||||
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 4):
|
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 4):
|
||||||
print("This example only works with Python 3.4 and greater")
|
print("This example only works with Python 3.4 and greater")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
port = 28332
|
port = 28332
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ XGETTEXT=os.getenv('XGETTEXT', 'xgettext')
|
|||||||
if not XGETTEXT:
|
if not XGETTEXT:
|
||||||
print('Cannot extract strings: xgettext utility is not installed or not configured.',file=sys.stderr)
|
print('Cannot extract strings: xgettext utility is not installed or not configured.',file=sys.stderr)
|
||||||
print('Please install package "gettext" and re-run \'./configure\'.',file=sys.stderr)
|
print('Please install package "gettext" and re-run \'./configure\'.',file=sys.stderr)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE)
|
child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE)
|
||||||
(out, err) = child.communicate()
|
(out, err) = child.communicate()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user