-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcmdline.py
More file actions
50 lines (46 loc) · 1.46 KB
/
Copy pathcmdline.py
File metadata and controls
50 lines (46 loc) · 1.46 KB
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
43
44
45
46
47
48
49
50
import sys,getopt
import numpy as np
def processCommandLine(argv):
scriptName=argv[0]
outDir=None
matList=None
useLapack=False
usage = "%s -m textFileWithMatrixA -m textFileWithMatrixB -m textFileWithMatrixD3 -o outputDir -l lapack"%(scriptName)
try:
opts, args = getopt.getopt(argv[1:], "ho:l:m:",["outputDir=","mat=","lapack="])
except getopt.GetoptError:
print usage
sys.exit(2)
if len(argv[1:]) % 2 != 0:
print "Incorrect Usage"
print "Usage:%s"%(usage)
sys.exit()
if not opts:
print "No command line arguments specified"
print usage
sys.exit()
for opt, arg in opts:
if opt=='-h':
print usage
sys.exit()
elif opt in ("-m","--mat"):
if arg:
if matList==None:
matList=list()
try:
matTemp=np.loadtxt(arg)
matList.append(matTemp)
except:
print "Unable to open file specified by:%s"%arg
else:
print "Matrix file name not specified\n"
sys.exit()
elif opt in ("-l","--lapack"):
useLapack=True
elif opt in ("-o","--outputDir"):
if arg:
outDir=arg
else:
print "output-directory not specified\n"
sys.exit()
return matList,outDir,useLapack