|
@@ -4,6 +4,13 @@ import schedule
|
|
import time
|
|
import time
|
|
from datetime import datetime
|
|
from datetime import datetime
|
|
from logger import logger
|
|
from logger import logger
|
|
|
|
+from config import Config
|
|
|
|
+
|
|
|
|
+# Set Config Parameters
|
|
|
|
+MARKET_POLL_INTERVAL = Config["gather"].get("MarketPollInterval",15)
|
|
|
|
+PLAYER_POLL_INTERVAL = Config["gather"].get("PlayerPollInterval",15)
|
|
|
|
+CollectPlayerData = Config["gather"].get("CollectPlayer",False)
|
|
|
|
+Login = Config["gather"].get("Login",False)
|
|
|
|
|
|
# Handle command arguments
|
|
# Handle command arguments
|
|
import argparse
|
|
import argparse
|
|
@@ -12,7 +19,6 @@ parser.add_argument(
|
|
"-p",
|
|
"-p",
|
|
"--player",
|
|
"--player",
|
|
metavar="yes/no",
|
|
metavar="yes/no",
|
|
- default='no',
|
|
|
|
choices=['yes','no'],
|
|
choices=['yes','no'],
|
|
help="Collect player data?"
|
|
help="Collect player data?"
|
|
)
|
|
)
|
|
@@ -20,17 +26,17 @@ parser.add_argument(
|
|
"-l",
|
|
"-l",
|
|
"--login",
|
|
"--login",
|
|
metavar="yes/no",
|
|
metavar="yes/no",
|
|
- default='no',
|
|
|
|
choices=['yes','no'],
|
|
choices=['yes','no'],
|
|
help="Login to Browser?"
|
|
help="Login to Browser?"
|
|
)
|
|
)
|
|
args = parser.parse_args()
|
|
args = parser.parse_args()
|
|
-CollectPlayerData = args.player
|
|
|
|
|
|
+if args.player is not None:
|
|
|
|
+ if args.player == 'yes': CollectPlayerData = True
|
|
|
|
+ else: CollectPlayerData = False
|
|
login_yesno = args.login
|
|
login_yesno = args.login
|
|
-if login_yesno == 'yes':
|
|
|
|
- Login = True
|
|
|
|
-else:
|
|
|
|
- Login = False
|
|
|
|
|
|
+if args.login is not None:
|
|
|
|
+ if args.login == 'yes': Login = True
|
|
|
|
+ else: Login = False
|
|
|
|
|
|
m=Market(login=Login)
|
|
m=Market(login=Login)
|
|
p=Player()
|
|
p=Player()
|
|
@@ -39,7 +45,7 @@ perr=0
|
|
|
|
|
|
|
|
|
|
def jobM():
|
|
def jobM():
|
|
- global m
|
|
|
|
|
|
+ global m,merr
|
|
logger.info("Gathering Market Data.")
|
|
logger.info("Gathering Market Data.")
|
|
try:
|
|
try:
|
|
m.fetchData()
|
|
m.fetchData()
|
|
@@ -53,7 +59,7 @@ def jobM():
|
|
m=Market()
|
|
m=Market()
|
|
|
|
|
|
def jobP():
|
|
def jobP():
|
|
- global p
|
|
|
|
|
|
+ global p,perr
|
|
logger.info("Gathering Player Data.")
|
|
logger.info("Gathering Player Data.")
|
|
try:
|
|
try:
|
|
p.fetchData()
|
|
p.fetchData()
|
|
@@ -66,11 +72,11 @@ def jobP():
|
|
perr=0
|
|
perr=0
|
|
p=Player()
|
|
p=Player()
|
|
|
|
|
|
-schedule.every(15).minutes.do(jobM)
|
|
|
|
|
|
+schedule.every(MARKET_POLL_INTERVAL).minutes.do(jobM)
|
|
jobM()
|
|
jobM()
|
|
|
|
|
|
if CollectPlayerData == 'yes':
|
|
if CollectPlayerData == 'yes':
|
|
- schedule.every(15).minutes.do(jobP)
|
|
|
|
|
|
+ schedule.every(PLAYER_POLL_INTERVAL).minutes.do(jobP)
|
|
jobP()
|
|
jobP()
|
|
|
|
|
|
while 1:
|
|
while 1:
|