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

Function apiData

src/bitmessagecli.py:159–221  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

157
158
159def apiData():
160 global keysName
161 global keysPath
162 global usrPrompt
163
164 BMConfigParser().read(keysPath) #First try to load the config file (the keys.dat file) from the program directory
165
166 try:
167 BMConfigParser().get('bitmessagesettings','port')
168 appDataFolder = ''
169 except:
170 #Could not load the keys.dat file in the program directory. Perhaps it is in the appdata directory.
171 appDataFolder = lookupAppdataFolder()
172 keysPath = appDataFolder + keysPath
173 BMConfigParser().read(keysPath)
174
175 try:
176 BMConfigParser().get('bitmessagesettings','port')
177 except:
178 #keys.dat was not there either, something is wrong.
179 print '\n ******************************************************************'
180 print ' There was a problem trying to access the Bitmessage keys.dat file'
181 print ' or keys.dat is not set up correctly'
182 print ' Make sure that daemon is in the same directory as Bitmessage. '
183 print ' ******************************************************************\n'
184
185 uInput = userInput("Would you like to create a keys.dat in the local directory, (Y)es or (N)o?").lower()
186
187 if (uInput == "y" or uInput == "yes"):
188 configInit()
189 keysPath = keysName
190 usrPrompt = 0
191 main()
192 elif (uInput == "n" or uInput == "no"):
193 print '\n Trying Again.\n'
194 usrPrompt = 0
195 main()
196 else:
197 print '\n Invalid Input.\n'
198
199 usrPrompt = 1
200 main()
201
202 try: #checks to make sure that everyting is configured correctly. Excluding apiEnabled, it is checked after
203 BMConfigParser().get('bitmessagesettings', 'apiport')
204 BMConfigParser().get('bitmessagesettings', 'apiinterface')
205 BMConfigParser().get('bitmessagesettings', 'apiusername')
206 BMConfigParser().get('bitmessagesettings', 'apipassword')
207 except:
208 apiInit("") #Initalize the keys.dat file with API information
209
210 #keys.dat file was found or appropriately configured, allow information retrieval
211 #apiEnabled = apiInit(BMConfigParser().safeGetBoolean('bitmessagesettings','apienabled')) #if false it will prompt the user, if true it will return true
212
213 BMConfigParser().read(keysPath)#read again since changes have been made
214 apiPort = int(BMConfigParser().get('bitmessagesettings', 'apiport'))
215 apiInterface = BMConfigParser().get('bitmessagesettings', 'apiinterface')
216 apiUsername = BMConfigParser().get('bitmessagesettings', 'apiusername')

Callers 1

mainFunction · 0.85

Calls 8

BMConfigParserClass · 0.90
userInputFunction · 0.85
configInitFunction · 0.85
apiInitFunction · 0.85
readMethod · 0.80
lookupAppdataFolderFunction · 0.70
mainFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected