forked from iteratedecks/fansiteSubmission
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfansiteConfig.py
More file actions
55 lines (48 loc) · 1.97 KB
/
fansiteConfig.py
File metadata and controls
55 lines (48 loc) · 1.97 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
51
52
53
54
import sys
import os
import argparse
def getDefaultConfig():
return """\
# Config file for use with Fansite submission script
# your simulation token (provided by the Fansite)
token=00000000000000000000000000000000
# the name of the simulator
simulator=Tyrant Optimizer
# the number of simulations per deck
numSims=1000000
# the number of CPU threads for simulation
numThreads=1
"""
def getArgs():
args = getCommandArgs()
args = getConfigArgs(args, args.config)
return args
def getCommandArgs():
argParser = argparse.ArgumentParser(description='Submit simulator results to the Fansite.')
argParser.add_argument('-t', '--test', action='store_const', default=0, const=1, help='run against test repo')
argParser.add_argument('--config', default='fansite_config.txt', help='path to config file')
argParser.add_argument('--token', help='simulator token')
argParser.add_argument('--simulator', help='simulator used')
argParser.add_argument('--numSims', help='number of simulations to run per deck')
argParser.add_argument('--numThreads', help='number of CPU threads for simulation')
argParser.add_argument('--limit', default=None, help='amount of decks to simulate')
argParser.add_argument('--runForever', action='store_const', default=0, const=1, help='run forever (Ctrl-Break to stop)')
args = argParser.parse_args()
return args
def getConfigArgs(args, config = "fansite_config.txt"):
contents = None
if(not os.path.exists(config)):
print("Could not find config file. Creating one with default settings.")
with open(config, 'w') as f:
contents = getDefaultConfig()
f.write(contents)
else:
with open(config, 'r') as f:
contents = f.read()
for line in contents.splitlines():
if(len(line) == 0 or line[0] == "#"):
continue
arg = line.split('=')
if getattr(args, arg[0], None) is None:
setattr(args, arg[0], arg[1])
return args