예제 #1
0
 def _init_local(self):
     from p2p import commands
     from lib import net_misc
     from lib import misc
     from system import tmpfile
     from system import run_upnpc
     from raid import eccmap
     from userid import my_id
     from crypt import my_keys
     my_id.init()
     if settings.enableWebStream():
         from logs import weblog
         weblog.init(settings.getWebStreamPort())
     if settings.enableWebTraffic():
         from logs import webtraffic
         webtraffic.init(port=settings.getWebTrafficPort())
     misc.init()
     commands.init()
     tmpfile.init(settings.getTempDir())
     net_misc.init()
     settings.update_proxy_settings()
     run_upnpc.init()
     eccmap.init()
     my_keys.init()
     if sys.argv.count('--twisted'):
         from twisted.python import log as twisted_log
         twisted_log.startLogging(MyTwistedOutputLog(), setStdout=0)
         # import twisted.python.failure as twisted_failure
         # twisted_failure.startDebugMode()
         # twisted_log.defaultObserver.stop()
     if settings.getDebugLevel() > 10:
         defer.setDebugging(True)
예제 #2
0
    def _init_local(self):
        from p2p import commands
        from lib import net_misc
        from lib import misc
        from system import tmpfile
        from system import run_upnpc
        from raid import eccmap
        from userid import my_id

        my_id.init()
        if settings.enableWebStream():
            from logs import weblog

            weblog.init(settings.getWebStreamPort())
        if settings.enableWebTraffic():
            from logs import webtraffic

            webtraffic.init(port=settings.getWebTrafficPort())
        misc.init()
        commands.init()
        tmpfile.init(settings.getTempDir())
        net_misc.init()
        settings.update_proxy_settings()
        run_upnpc.init()
        eccmap.init()
        if sys.argv.count("--twisted"):
            from twisted.python import log as twisted_log

            twisted_log.startLogging(MyTwistedOutputLog(), setStdout=0)
            # import twisted.python.failure as twisted_failure
            # twisted_failure.startDebugMode()
            # twisted_log.defaultObserver.stop()
        if settings.getDebugLevel() > 10:
            defer.setDebugging(True)
예제 #3
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
예제 #4
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.GetBaseDir())
    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.percent2string(float(r['total']) / float(r['disktotal']), 5)
    except:
        r['total_percent'] = ''
    try:
        r['diskfree_percent'] = misc.percent2string(float(r['diskfree']) / float(r['disktotal']), 5)
    except:
        r['diskfree_percent'] = ''
    return r
예제 #5
0
 def _init_local(self):
     from p2p import commands
     from lib import net_misc
     from lib import misc
     from system import tmpfile
     from system import run_upnpc
     from raid import eccmap
     from contacts import identitydb
     from crypt import my_keys
     from userid import id_url
     from userid import my_id
     id_url.init()
     identitydb.init()
     my_id.init()
     if settings.enableWebStream():
         try:
             from logs import weblog
             weblog.init(settings.getWebStreamPort())
         except:
             lg.exc()
     if settings.enableWebTraffic():
         try:
             from logs import webtraffic
             webtraffic.init(port=settings.getWebTrafficPort())
         except:
             lg.exc()
     misc.init()
     commands.init()
     tmpfile.init(settings.getTempDir())
     net_misc.init()
     settings.update_proxy_settings()
     run_upnpc.init()
     eccmap.init()
     my_keys.init()
     # if sys.argv.count('--twisted'):
     #     from twisted.python import log as twisted_log
     #     twisted_log.startLogging(MyTwistedOutputLog(), setStdout=0)
         # import twisted.python.failure as twisted_failure
         # twisted_failure.startDebugMode()
         # twisted_log.defaultObserver.stop()
     # if settings.getDebugLevel() > 10:
     #     defer.setDebugging(True)
     if settings.enableMemoryProfile():
         try:
             from guppy import hpy  # @UnresolvedImport
             hp = hpy()
             hp.setrelheap()
             if _Debug:
                 lg.out(_DebugLevel, 'hp.heap():\n'+str(hp.heap()))
                 lg.out(_DebugLevel, 'hp.heap().byrcs:\n'+str(hp.heap().byrcs))
                 lg.out(_DebugLevel, 'hp.heap().byvia:\n'+str(hp.heap().byvia))
         except:
             if _Debug:
                 lg.out(_DebugLevel, "guppy package is not installed")
     if _Debug:
         lg.dbg(_DebugLevel, 'all local modules are initialized, ready to start the engine')
예제 #6
0
    import pprint
    pprint.pprint(backup_fs.fsID())
    pprint.pprint(backup_fs.fs())
    print backup_fs.GetByID('0')
    # pprint.pprint(backup_fs.WalkByID('0/0/2/19/F20140106100849AM'))
    # for pathID, localPath, item in backup_fs.IterateIDs():
    #     print pathID, misc.unicode_to_str_safe(localPath)
    # backup_fs.TraverseByIDSorted(lambda x, y, z: sys.stdout.write('%s %s\n' % (x,misc.unicode_to_str_safe(y))))


def test2():
    """
    For tests.
    """
    # reactor.callLater(1, StartDirRecursive, 'c:/temp')
    reactor.run()

#------------------------------------------------------------------------------


if __name__ == "__main__":
    bpio.init()
    lg.set_debug_level(20)
    settings.init()
    tmpfile.init(settings.getTempDir())
    contactsdb.init()
    eccmap.init()
    key.InitMyKey()
    init()
    test()
예제 #7
0
#    print backup_fs.sizebackups()
    import pprint
    pprint.pprint(backup_fs.fsID())
    pprint.pprint(backup_fs.fs())
    print backup_fs.GetByID('0')
    # pprint.pprint(backup_fs.WalkByID('0/0/2/19/F20140106100849AM'))
    # for pathID, localPath, item in backup_fs.IterateIDs():
    #     print pathID, misc.unicode_to_str_safe(localPath)
    # backup_fs.TraverseByIDSorted(lambda x, y, z: sys.stdout.write('%s %s\n' % (x,misc.unicode_to_str_safe(y))))


def test2():
    """
    For tests.
    """
    # reactor.callLater(1, StartDirRecursive, 'c:/temp')
    reactor.run()

#------------------------------------------------------------------------------

if __name__ == "__main__":
    bpio.init()
    lg.set_debug_level(20)
    settings.init()
    tmpfile.init(settings.getTempDir())
    contactsdb.init()
    eccmap.init()
    key.InitMyKey()
    init()
    test()