MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / defPaths

Function defPaths

config.py:119–220  ·  view source on GitHub ↗
(customSavePath=None)

Source from the content-addressed store, hash-verified

117
118
119def defPaths(customSavePath=None):
120 global debug
121 global pyfaPath
122 global savePath
123 global saveDB
124 global gameDB
125 global imgsZIP
126 global saveInRoot
127 global logPath
128 global cipher
129 global clientHash
130 global version
131 global experimentalFeatures
132 global language
133
134 pyfalog.debug("Configuring Pyfa")
135
136 # The main pyfa directory which contains run.py
137 # Python 2.X uses ANSI by default, so we need to convert the character encoding
138 pyfaPath = getattr(configforced, "pyfaPath", pyfaPath)
139 if pyfaPath is None:
140 pyfaPath = getPyfaRoot()
141
142 # Version data
143
144 with open(os.path.join(pyfaPath, "version.yml"), 'r') as file:
145 data = yaml.load(file, Loader=yaml.SafeLoader)
146 version = data['version']
147
148 # Where we store the saved fits etc, default is the current users home directory
149 if saveInRoot is True:
150 savePath = getattr(configforced, "savePath", None)
151 if savePath is None:
152 savePath = os.path.join(pyfaPath, "saveddata")
153 else:
154 savePath = getattr(configforced, "savePath", None)
155 if savePath is None:
156 if customSavePath is None: # customSavePath is not overriden
157 savePath = getDefaultSave()
158 else:
159 savePath = customSavePath
160
161 __createDirs(savePath)
162
163 secret_file = os.path.join(savePath, ".secret")
164 if not os.path.exists(secret_file):
165 with open(secret_file, "wb") as _file:
166 _file.write(Fernet.generate_key())
167
168 with open(secret_file, 'rb') as fp:
169 key = fp.read()
170 clientHash = hashlib.sha3_256(key).hexdigest()
171 cipher = Fernet(key)
172
173 # if isFrozen():
174 # os.environ["REQUESTS_CA_BUNDLE"] = os.path.join(pyfaPath, "cacert.pem")
175 # os.environ["SSL_CERT_FILE"] = os.path.join(pyfaPath, "cacert.pem")
176

Callers

nothing calls this directly

Calls 7

getPyfaRootFunction · 0.85
getDefaultSaveFunction · 0.85
__createDirsFunction · 0.85
get_eos_localeMethod · 0.80
writeMethod · 0.45
getInstanceMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected