示例#1
0
def report_local_storage():
    # TODO
    # if customers folder placed outside of BaseDir()
    # need to add: total = total + customers
    r = {}
    r['backups'] = bpio.getDirectorySize(settings.getLocalBackupsDir())
    # r['backups_str'] = diskspace.MakeStringFromBytes(r['backups'])
    r['temp'] = bpio.getDirectorySize(settings.getTempDir())
    # r['temp_str'] = diskspace.MakeStringFromBytes(r['temp'])
    r['customers'] = bpio.getDirectorySize(settings.getCustomersFilesDir())
    # r['customers_str'] = diskspace.MakeStringFromBytes(r['customers'])
    r['total'] = bpio.getDirectorySize(settings.BaseDir())
    # r['total_str'] = diskspace.MakeStringFromBytes(r['total'])
    dataDriveFreeSpace, dataDriveTotalSpace = diskusage.GetDriveSpace(
        settings.getCustomersFilesDir())
    if dataDriveFreeSpace is None:
        dataDriveFreeSpace = 0
    r['disktotal'] = int(dataDriveTotalSpace)
    # r['disktotal_str'] = diskspace.MakeStringFromBytes(r['disktotal'])
    r['diskfree'] = int(dataDriveFreeSpace)
    # r['diskfree_str'] = diskspace.MakeStringFromBytes(r['diskfree'])
    try:
        r['total_percent'] = misc.value2percent(float(r['total']),
                                                float(r['disktotal']), 5)
    except:
        r['total_percent'] = ''
    try:
        r['diskfree_percent'] = misc.value2percent(float(r['diskfree']),
                                                   float(r['disktotal']), 5)
    except:
        r['diskfree_percent'] = ''
    return r
示例#2
0
def make(callback=None):
    """
    """
    geth_location = os.path.join(settings.BaseDir(), "ethereum", "go-ethereum")
    execute(['make', 'geth'],
            base_dir=geth_location,
            env=os.environ,
            callback=callback)
def run_geth_node():
    """
    """
    geth_datadir = os.path.join(settings.BaseDir(), "ethereum", "datadir")
    if not os.path.isdir(geth_datadir):
        os.makedirs(geth_datadir)
    run(['--datadir="{}"'.format(geth_datadir),
         '--verbosity', '4', '--ipcdisable', '--port', '30300', '--rpcport', '8100', '--networkid', '1'])
示例#4
0
def run(cmdargs, callback=None):
    """
    """
    geth_location = os.path.join(
        settings.BaseDir(),
        "ethereum",
        "go-ethereum",
    )
    cmdargs = [
        'build/bin/geth',
    ] + cmdargs
    execute(cmdargs, base_dir=geth_location, env=os.environ, callback=callback)
def verify_local_install():
    """
    """
    ethereum_location = os.path.join(settings.BaseDir(), "ethereum")
    if not os.path.isdir(ethereum_location):
        raise ValueError('Ethereum root location not found: {}'.format(ethereum_location))
    geth_location = os.path.join(ethereum_location, 'go-ethereum')
    if not os.path.isdir(ethereum_location):
        raise ValueError('Ethereum geth process folder not found: {}'.format(ethereum_location))
    geth_bin_path = os.path.join(geth_location, 'build', 'bin', 'geth')
    if not os.path.isfile(geth_bin_path):
        raise ValueError('Ethereum geth process executable not found: {}'.format(geth_bin_path))
    return True
示例#6
0
 def do_restart(param):
     from lib import misc
     from system import bpio
     from main import settings
     settings.init()
     appdata = settings.BaseDir()
     detach = False
     if bpio.Windows():
         detach = True
     misc.DoRestart(
         param,
         detach=detach,
         std_out=os.path.join(appdata, 'logs', 'stdout.log'),
         std_err=os.path.join(appdata, 'logs', 'stderr.log'),
     )
def clone(callback=None):
    """
    """
    ethereum_location = os.path.join(settings.BaseDir(), "ethereum")
    if not os.path.isdir(ethereum_location):
        os.makedirs(ethereum_location)
    geth_location = os.path.join(ethereum_location, 'go-ethereum')
    if os.path.exists(geth_location):
        bpio.rmdir_recursive(geth_location)
    git_proc.run(
        ['clone', '--verbose', '--depth', '1', 'https://github.com/ethereum/go-ethereum', geth_location, ],
        base_dir=ethereum_location,
        env=os.environ,
        callback_func=callback,
    )