forked from EstevanTH/CAN-Monitoring_ELM327
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configselector.py
42 lines (36 loc) · 1.08 KB
/
configselector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def _():
global parametersFile
global sequenceFile
import os
from sys import argv
from os.path import isfile
applicationDirectory = os.path.dirname(__file__) + os.path.sep
parametersFile = applicationDirectory+"config/parameters.py"
sequenceFile = applicationDirectory+"config/sequenceELM327_CAN.py"
def fixPath( filename ):
fixedPath = None
attemptedPaths = [
filename,
applicationDirectory+"config/"+filename,
]
for attemptedPath in attemptedPaths:
if isfile( attemptedPath ):
fixedPath = attemptedPath
break
return fixedPath
for argument in argv:
if argument[:13]=="--parameters=":
parametersFile = fixPath( argument[13:] )
break
for argument in argv:
if argument[:11]=="--sequence=":
sequenceFile = fixPath( argument[11:] )
break
_();del _
if parametersFile is None:
print( "Could not locate the file specified for --parameters!" )
if sequenceFile is None:
print( "Could not locate the file specified for --sequence!" )
if __name__=="__main__":
print( "parametersFile =", parametersFile )
print( "sequenceFile =", sequenceFile )