MCPcopy Index your code
hub / github.com/algorithmiaio/algorithmia-python / getconfigfile

Method getconfigfile

Algorithmia/CLI.py:315–344  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

313
314
315 def getconfigfile(self):
316 if (os.name == "posix"):
317 # if!windows
318 # ~/.algorithmia/config
319 # create the api key file if it does not exist
320 keyPath = os.environ['HOME'] + "/.algorithmia/"
321
322 elif (os.name == "nt"):
323 # ifwindows
324 # %LOCALAPPDATA%\Algorithmia\config
325 # create the api key file if it does not exist
326 keyPath = os.path.expandvars("%LOCALAPPDATA%\\Algorithmia\\")
327
328 keyFile = "config"
329
330 if (not os.path.exists(keyPath)):
331 os.mkdir(keyPath)
332
333 if (not os.path.exists(keyPath + keyFile)):
334 with open(keyPath + keyFile, "w") as file:
335 file.write("[profiles]\n")
336 file.write("[profiles.default]\n")
337 file.write("api_key = ''\n")
338 file.write("api_server = ''\n")
339 file.write("ca_cert = ''\n")
340 file.write("bearer_token = ''\n")
341
342 key = keyPath + keyFile
343
344 return key
345
346 def get_template(self, envid, dest, client):
347 response = client.get_template(envid, dest)

Callers 5

authMethod · 0.95
getAPIkeyMethod · 0.95
getBearerTokenMethod · 0.95
getAPIaddressMethod · 0.95
getCertMethod · 0.95

Calls 2

mkdirMethod · 0.80
existsMethod · 0.45

Tested by

no test coverage detected