Esempio n. 1
0
def keosd_start():
    if not config.keosd_wallet_dir(raise_error=False):
        utils.process([config.keosd_exe()])

        while True:
            time.sleep(1)
            if config.keosd_wallet_dir(raise_error=False):
                break
Esempio n. 2
0
def get_eosio_cpp_version():
    """Get the version code of *eosio-cpp*.
    """
    return utils.process(
                            [config.eosio_cpp(), "-version"],
                            "Cannot determine the version of 'eosio-cpp'."
        ).replace("eosio-cpp version ", "")
Esempio n. 3
0
def read_map(file_name, text_editor="nano"):
    '''Return json account map

Attempt to open the account map file named ``setup.account_map``, located 
in the wallet directory ``config.keosd_wallet_dir()``, to return its json 
contents. If the file does not exist, return an empty json.

If the file is corrupted, offer editing the file with the ``nano`` linux 
editor. Return ``None`` if the the offer is rejected.
    '''
    wallet_dir_ = config.keosd_wallet_dir()
    path = os.path.join(wallet_dir_, file_name)
    while True:
        try: # whether the setup map file exists:
            with open(path, "r") as input_file:
                return json.load(input_file)

        except Exception as e:
            if isinstance(e, FileNotFoundError):
                return {}
            else:
                raise errors.Error('''
            The json file 
            {}
            is misformed. The error message is:
            {}
            
            Do you want to edit the file?
            '''.format(str(path), str(e)), is_fatal=False, translate=False)
                    
                answer = input("y/n <<< ")
                if answer == "y":
                    utils.process([text_editor, path])
                    continue
                else:
                    raise errors.Error('''
                    Use the function 'manager.edit_account_map(text_editor="nano")' to edit the file.
                    ''', translate=False)                    
                    return None
Esempio n. 4
0
def get_pid(name=None):
    """Return process ids found by (partial) name or regex.

    >>> get_process_id('kthreadd')
    [2]
    >>> get_process_id('watchdog')
    [10, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61]  # ymmv
    >>> get_process_id('non-existent process')
    []
    """    
    if not name:
        name = os.path.splitext(os.path.basename(config.node_exe()))[0]

    command_line = ['pgrep', '-f', name]
    stdout = utils.process(
        command_line, "Cannot determine PID of any nodeos process.")

    return [int(pid) for pid in stdout.split()]
Esempio n. 5
0
def is_local_node_process_running(name=None):
    if not name:
        name = config.node_exe()
    return name in utils.process(
        'ps aux |  grep -v grep | grep ' + name, shell=True)
Esempio n. 6
0
def uname(options=None):
    command_line = ['uname']
    if options:
        command_line.append(options)

    return utils.process(command_line)
Esempio n. 7
0
def edit_map(file_name, text_editor="nano"):
    utils.process([text_editor, os.path.join(
                                    config.keosd_wallet_dir(), file_name)])
    read_map(file_name, text_editor)