Skip to content
Snippets Groups Projects
Commit 728d15df authored by Moul's avatar Moul
Browse files

[lint] Use sys.exit() instead of exit()

parent b05c6dec
No related branches found
No related tags found
2 merge requests!94Merge dev into master for release 0.56.0,!82[lint] Use sys.exit() instead of exit()
Pipeline #6905 skipped
from duniterpy.key import SigningKey from duniterpy.key import SigningKey
import getpass import getpass
import os import os
import sys
if "XDG_CONFIG_HOME" in os.environ: if "XDG_CONFIG_HOME" in os.environ:
home_path = os.environ["XDG_CONFIG_HOME"] home_path = os.environ["XDG_CONFIG_HOME"]
...@@ -35,7 +36,7 @@ signer = SigningKey.from_credentials(salt, password) ...@@ -35,7 +36,7 @@ signer = SigningKey.from_credentials(salt, password)
# check public key # check public key
if signer.pubkey != pubkey: if signer.pubkey != pubkey:
print("Bad credentials!") print("Bad credentials!")
exit(1) sys.exit(1)
# save private keys in a file (json format) # save private keys in a file (json format)
signer.save_private_key(PRIVATE_KEYS_FILE_PATH) signer.save_private_key(PRIVATE_KEYS_FILE_PATH)
...@@ -49,4 +50,4 @@ loaded_signer = SigningKey.from_private_key(PRIVATE_KEYS_FILE_PATH) # type: Sig ...@@ -49,4 +50,4 @@ loaded_signer = SigningKey.from_private_key(PRIVATE_KEYS_FILE_PATH) # type: Sig
# check public key from file # check public key from file
print("Public key %s loaded from file %s" % (pubkey, PRIVATE_KEYS_FILE_PATH)) print("Public key %s loaded from file %s" % (pubkey, PRIVATE_KEYS_FILE_PATH))
exit(0) sys.exit(0)
from duniterpy.key import SigningKey from duniterpy.key import SigningKey
import getpass import getpass
import os import os
import sys
if "XDG_CONFIG_HOME" in os.environ: if "XDG_CONFIG_HOME" in os.environ:
home_path = os.environ["XDG_CONFIG_HOME"] home_path = os.environ["XDG_CONFIG_HOME"]
...@@ -35,7 +36,7 @@ signer = SigningKey.from_credentials(salt, password) ...@@ -35,7 +36,7 @@ signer = SigningKey.from_credentials(salt, password)
# check public key # check public key
if signer.pubkey != pubkey: if signer.pubkey != pubkey:
print("Bad credentials!") print("Bad credentials!")
exit(1) sys.exit(1)
# prompt hidden user entry # prompt hidden user entry
ewif_password = getpass.getpass("Enter an encryption password: ") ewif_password = getpass.getpass("Enter an encryption password: ")
...@@ -62,7 +63,7 @@ try: ...@@ -62,7 +63,7 @@ try:
except IOError as error: except IOError as error:
print(error) print(error)
exit(1) sys.exit(1)
exit(0) sys.exit(0)
from duniterpy.key import SigningKey from duniterpy.key import SigningKey
import getpass import getpass
import os import os
import sys
if "XDG_CONFIG_HOME" in os.environ: if "XDG_CONFIG_HOME" in os.environ:
home_path = os.environ["XDG_CONFIG_HOME"] home_path = os.environ["XDG_CONFIG_HOME"]
...@@ -35,7 +36,7 @@ signer = SigningKey.from_credentials(salt, password) ...@@ -35,7 +36,7 @@ signer = SigningKey.from_credentials(salt, password)
# check public key # check public key
if signer.pubkey != pubkey: if signer.pubkey != pubkey:
print("Bad credentials!") print("Bad credentials!")
exit(1) sys.exit(1)
# save private key in a file (PubSec v1 format) # save private key in a file (PubSec v1 format)
signer.save_pubsec_file(PRIVATE_KEY_FILE_PATH) signer.save_pubsec_file(PRIVATE_KEY_FILE_PATH)
...@@ -57,7 +58,7 @@ try: ...@@ -57,7 +58,7 @@ try:
except IOError as error: except IOError as error:
print(error) print(error)
exit(1) sys.exit(1)
exit(0) sys.exit(0)
from duniterpy.key import SigningKey from duniterpy.key import SigningKey
import getpass import getpass
import os import os
import sys
if "XDG_CONFIG_HOME" in os.environ: if "XDG_CONFIG_HOME" in os.environ:
home_path = os.environ["XDG_CONFIG_HOME"] home_path = os.environ["XDG_CONFIG_HOME"]
...@@ -35,7 +36,7 @@ signer = SigningKey.from_credentials(salt, password) ...@@ -35,7 +36,7 @@ signer = SigningKey.from_credentials(salt, password)
# check public key # check public key
if signer.pubkey != pubkey: if signer.pubkey != pubkey:
print("Bad credentials!") print("Bad credentials!")
exit(1) sys.exit(1)
# save private key in a file (WIF v1 format) # save private key in a file (WIF v1 format)
signer.save_wif_file(PRIVATE_KEY_FILE_PATH) signer.save_wif_file(PRIVATE_KEY_FILE_PATH)
...@@ -57,7 +58,7 @@ try: ...@@ -57,7 +58,7 @@ try:
except IOError as error: except IOError as error:
print(error) print(error)
exit(1) sys.exit(1)
exit(0) sys.exit(0)
import asyncio import asyncio
import getpass import getpass
import os import os
import sys
from typing import Optional from typing import Optional
import duniterpy.api.bma as bma import duniterpy.api.bma as bma
...@@ -123,7 +124,7 @@ async def main(): ...@@ -123,7 +124,7 @@ async def main():
# check public key # check public key
if signer.pubkey != pubkey: if signer.pubkey != pubkey:
print("Bad credentials!") print("Bad credentials!")
exit(0) sys.exit(0)
# capture current block to get currency name # capture current block to get currency name
current_block = await client(bma.blockchain.current) current_block = await client(bma.blockchain.current)
...@@ -134,7 +135,7 @@ async def main(): ...@@ -134,7 +135,7 @@ async def main():
print("Identity not found for pubkey {0}".format(pubkey)) print("Identity not found for pubkey {0}".format(pubkey))
# Close client aiohttp session # Close client aiohttp session
await client.close() await client.close()
exit(1) sys.exit(1)
# get the revoke document # get the revoke document
revocation_signed_raw_document = get_signed_raw_revocation_document( revocation_signed_raw_document = get_signed_raw_revocation_document(
......
import sys
import asyncio import asyncio
import getpass import getpass
from typing import Optional from typing import Optional
...@@ -114,7 +115,7 @@ async def main(): ...@@ -114,7 +115,7 @@ async def main():
print("Identity not found for pubkey {0}".format(pubkey_to)) print("Identity not found for pubkey {0}".format(pubkey_to))
# Close client aiohttp session # Close client aiohttp session
await client.close() await client.close()
exit(1) sys.exit(1)
# send the Certification document to the node # send the Certification document to the node
certification = get_certification_document(current_block, identity, pubkey_from) certification = get_certification_document(current_block, identity, pubkey_from)
......
import sys
import asyncio import asyncio
import getpass import getpass
...@@ -120,7 +121,7 @@ async def main(): ...@@ -120,7 +121,7 @@ async def main():
if len(response["sources"]) == 0: if len(response["sources"]) == 0:
print("no sources found for account %s" % pubkey_to) print("no sources found for account %s" % pubkey_to)
exit(1) sys.exit(1)
# get the first source # get the first source
source = response["sources"][0] source = response["sources"][0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment