diff --git a/src/cert.py b/src/cert.py index 1e861a7eb77b410c850aad7e42edecbc227b9b61..4625ac2671e028c8e1fe987649e393d77ca0212f 100644 --- a/src/cert.py +++ b/src/cert.py @@ -1,13 +1,10 @@ -import webbrowser import urllib - -from sys import exit -from pydoc import pager from tabulate import tabulate from auth import auth_method from tools import get_publickey_from_seed, message_exit, sign_document_from_seed from network_tools import get_current_block, post_request +from license import license_approval from constants import NO_MATCHING_ID from wot import is_member, get_pubkey_from_id, get_pubkeys_from_id,\ get_uid_from_pubkey @@ -55,21 +52,6 @@ def send_certification(ep, cli_args): print("Certification successfully sent.") -def license_approval(currency): - if currency != "g1": - return - language = input("In which language would you like to display Ğ1 license [en/fr]? ") - if (language == "en"): - if not webbrowser.open("https://duniter.org/en/get-g1/"): - pager(open("licence-G1/license/license_g1-en.rst").read()) - else: - if not webbrowser.open("https://duniter.org/fr/wiki/licence-g1/"): - pager(open("licence-G1/license/license_g1-fr-FR.rst").read()) - - if (input("Do you approve Ğ1 license [yes/no]? ") != "yes"): - exit(1) - - def certification_confirmation(issuer_id, issuer_pubkey, certified_uid, certified_pubkey): cert = list() cert.append(["Cert", "From", "–>", "To"]) diff --git a/src/license.py b/src/license.py new file mode 100644 index 0000000000000000000000000000000000000000..3cdc4c90d72b72fbab58acd91dec9b7689512699 --- /dev/null +++ b/src/license.py @@ -0,0 +1,21 @@ +import webbrowser +from pydoc import pager +from sys import exit + + +def license_approval(currency): + if currency != "g1": + return + display_license() + if (input("Do you approve Ğ1 license [yes/no]? ") != "yes"): + exit(1) + + +def display_license(): + language = input("In which language would you like to display Ğ1 license [en/fr]? ") + if (language == "en"): + if not webbrowser.open("https://duniter.org/en/wiki/g1-license/"): + pager(open("licence-G1/license/license_g1-en.rst").read()) + else: + if not webbrowser.open("https://duniter.org/fr/wiki/licence-g1/"): + pager(open("licence-G1/license/license_g1-fr-FR.rst").read()) diff --git a/src/silkaj.py b/src/silkaj.py index 8d4dbce386edb7d79a5ffd05abde6641ac51f8ab..7af7417bc161e8e2a1eddc9f52df31f082855ce0 100755 --- a/src/silkaj.py +++ b/src/silkaj.py @@ -12,6 +12,7 @@ from tools import message_exit from network_tools import check_port, best_node from wot import received_sent_certifications, id_pubkey_correspondence from auth import generate_auth_file +from license import display_license from constants import SILKAJ_VERSION, G1_SYMBOL, GTEST_SYMBOL, G1_DEFAULT_ENDPOINT, G1_TEST_DEFAULT_ENDPOINT @@ -67,7 +68,9 @@ def usage(): \n it could autocomplete the pubkey corresponding to an identity with three or four following characters.\ \n \ \n - wot <pubkey> or <identity>: display received and sent certifications for an account.\ - \n\ + \n \ + \n - license: display Ğ1 currency license.\ + \n \ \nAuthentication:\ \n for amount, transaction, certification, and generate_auth_file commands\ \n - Scrypt is the default authentication method with 4096,16,1 as default values\ @@ -80,7 +83,7 @@ def usage(): def cli(): # ep: endpoint, node's network interface ep, cli_args = dict(), Command() - subcmd = ["about", "info", "diffi", "net", "network", "issuers", "argos", "amount", "tx", "transaction", "cert", "generate_auth_file", "id", "identities", "wot"] + subcmd = ["license", "about", "info", "diffi", "net", "network", "issuers", "argos", "amount", "tx", "transaction", "cert", "generate_auth_file", "id", "identities", "wot"] if cli_args.is_version_request(): message_exit(SILKAJ_VERSION) if cli_args.is_help_request() or cli_args.is_usage_request() or cli_args.subcmd not in subcmd: @@ -136,6 +139,9 @@ def manage_cmd(ep, c): elif cli_args.subcmd == "wot": received_sent_certifications(ep, cli_args.subsubcmd) + elif cli_args.subcmd == "license": + display_license() + def about(): print("\