def init_local(UI=""): """ Run `init()` method in most important modules. """ global UImode UImode = UI dhnio.Dprint(2, "dhninit.init_local") import lib.settings as settings import lib.misc as misc misc.init() misc.UpdateSettings() settings_patch() import lib.commands as commands commands.init() if sys.argv.count("--twisted"): class MyTwistedOutputLog: softspace = 0 def read(self): pass def write(self, s): dhnio.Dprint(0, s.strip()) def flush(self): pass def close(self): pass 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() from twisted.internet import defer defer.setDebugging(True) if settings.enableWebStream(): misc.StartWebStream() # if settings.enableWebTraffic(): # misc.StartWebTraffic() if settings.enableMemoryProfile(): try: from guppy import hpy hp = hpy() hp.setrelheap() dhnio.Dprint(2, "hp.heap():\n" + str(hp.heap())) dhnio.Dprint(2, "hp.heap().byrcs:\n" + str(hp.heap().byrcs)) dhnio.Dprint(2, "hp.heap().byvia:\n" + str(hp.heap().byvia)) import guppy.heapy.RM except: dhnio.Dprint(2, "dhninit.init_local guppy package is not installed") import lib.tmpfile as tmpfile tmpfile.init(settings.getTempDir()) import lib.dhnnet as dhnnet dhnnet.init() settings.update_proxy_settings() import run_upnpc run_upnpc.init() import lib.eccmap as eccmap eccmap.init() import lib.dhncrypto as dhncrypto import lib.identity as identity import webcontrol import lib.automats as automats webcontrol.GetGlobalState = automats.get_global_state automats.SetGlobalStateNotifyFunc(webcontrol.OnGlobalStateChanged) import lib.automat as automat automat.SetStateChangedCallback(webcontrol.OnSingleStateChanged) import dhnupdate dhnupdate.SetNewVersionNotifyFunc(webcontrol.OnGlobalVersionReceived) start_logs_rotate()
# 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__": dhnio.init() dhnio.SetDebug(20) settings.init() tmpfile.init(settings.getTempDir()) contacts.init() eccmap.init() dhncrypto.InitMyKey() init() test()