コード例 #1
0
ファイル: initializer.py プロジェクト: vesellov/bitdust.devel
    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)
コード例 #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
     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)
コード例 #3
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')
コード例 #4
0
def Validate():
    """
    Check all packets to be valid.
    """
    printlog('Validate ' + str(time.strftime("%a, %d %b %Y %H:%M:%S +0000")))
    contactsdb.init()
    commands.init()
    customers_dir = settings.getCustomersFilesDir()
    if not os.path.exists(customers_dir):
        return
    for customer_filename in os.listdir(customers_dir):
        onecustdir = os.path.join(customers_dir, customer_filename)
        if not os.path.isdir(onecustdir):
            continue
        for key_alias_filename in os.listdir(onecustdir):
            onekeydir = os.path.join(onecustdir, key_alias_filename)
            if not os.path.isdir(onekeydir):
                continue

            def cb(path, subpath, name):
                #             if not os.access(path, os.R_OK | os.W_OK):
                #                 return False
                if not os.path.isfile(path):
                    return True
    #             if name in [settings.BackupIndexFileName(),]:
    #                 return False
                packetsrc = bpio.ReadBinaryFile(path)
                if not packetsrc:
                    try:
                        os.remove(path)  # if is is no good it is of no use to anyone
                        printlog('Validate ' + path + ' removed (empty file)')
                    except:
                        printlog('Validate ERROR removing ' + path)
                        return False
                p = signed.Unserialize(packetsrc)
                if p is None:
                    try:
                        os.remove(path)  # if is is no good it is of no use to anyone
                        printlog('Validate ' + path + ' removed (unserialize error)')
                    except:
                        printlog('Validate ERROR removing ' + path)
                        return False
                result = p.Valid()
                packetsrc = ''
                del p
                if not result:
                    try:
                        os.remove(path)  # if is is no good it is of no use to anyone
                        printlog('Validate ' + path + ' removed (invalid packet)')
                    except:
                        printlog('Validate ERROR removing ' + path)
                        return False
                time.sleep(0.1)
                return False
            bpio.traverse_dir_recursive(cb, onekeydir)