MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / loadConfig

Function loadConfig

src/helper_startup.py:29–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 state.trustedPeer = state.Peer(host, int(port))
28
29def loadConfig():
30 if state.appdata:
31 BMConfigParser().read(state.appdata + 'keys.dat')
32 #state.appdata must have been specified as a startup option.
33 try:
34 BMConfigParser().get('bitmessagesettings', 'settingsversion')
35 print 'Loading config files from directory specified on startup: ' + state.appdata
36 needToCreateKeysFile = False
37 except:
38 needToCreateKeysFile = True
39
40 else:
41 BMConfigParser().read(paths.lookupExeFolder() + 'keys.dat')
42 try:
43 BMConfigParser().get('bitmessagesettings', 'settingsversion')
44 print 'Loading config files from same directory as program.'
45 needToCreateKeysFile = False
46 state.appdata = paths.lookupExeFolder()
47 except:
48 # Could not load the keys.dat file in the program directory. Perhaps it
49 # is in the appdata directory.
50 state.appdata = paths.lookupAppdataFolder()
51 BMConfigParser().read(state.appdata + 'keys.dat')
52 try:
53 BMConfigParser().get('bitmessagesettings', 'settingsversion')
54 print 'Loading existing config files from', state.appdata
55 needToCreateKeysFile = False
56 except:
57 needToCreateKeysFile = True
58
59 if needToCreateKeysFile:
60 # This appears to be the first time running the program; there is
61 # no config file (or it cannot be accessed). Create config file.
62 BMConfigParser().add_section('bitmessagesettings')
63 BMConfigParser().set('bitmessagesettings', 'settingsversion', '10')
64 BMConfigParser().set('bitmessagesettings', 'port', '8444')
65 BMConfigParser().set(
66 'bitmessagesettings', 'timeformat', '%%c')
67 BMConfigParser().set('bitmessagesettings', 'blackwhitelist', 'black')
68 BMConfigParser().set('bitmessagesettings', 'startonlogon', 'false')
69 if 'linux' in sys.platform:
70 BMConfigParser().set(
71 'bitmessagesettings', 'minimizetotray', 'false')
72 # This isn't implimented yet and when True on
73 # Ubuntu causes Bitmessage to disappear while
74 # running when minimized.
75 else:
76 BMConfigParser().set(
77 'bitmessagesettings', 'minimizetotray', 'true')
78 BMConfigParser().set(
79 'bitmessagesettings', 'showtraynotifications', 'true')
80 BMConfigParser().set('bitmessagesettings', 'startintray', 'false')
81 BMConfigParser().set('bitmessagesettings', 'socksproxytype', 'none')
82 BMConfigParser().set(
83 'bitmessagesettings', 'sockshostname', 'localhost')
84 BMConfigParser().set('bitmessagesettings', 'socksport', '9050')
85 BMConfigParser().set(
86 'bitmessagesettings', 'socksauthentication', 'false')

Callers

nothing calls this directly

Calls 7

BMConfigParserClass · 0.90
ensureNamecoinOptionsFunction · 0.90
_loadTrustedPeerFunction · 0.85
readMethod · 0.80
setMethod · 0.80
getMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected