diff options
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -63,7 +63,8 @@ def make_order(market, value, currency, action="acquire", | |||
63 | def get_user_market(config_path, user_id, debug=False): | 63 | def get_user_market(config_path, user_id, debug=False): |
64 | pg_config, report_path = parse_config(config_path) | 64 | pg_config, report_path = parse_config(config_path) |
65 | market_config = list(fetch_markets(pg_config, str(user_id)))[0][0] | 65 | market_config = list(fetch_markets(pg_config, str(user_id)))[0][0] |
66 | return market.Market.from_config(market_config, debug=debug) | 66 | args = type('Args', (object,), { "debug": debug, "quiet": False })() |
67 | return market.Market.from_config(market_config, args, user_id=user_id, report_path=report_path) | ||
67 | 68 | ||
68 | def fetch_markets(pg_config, user): | 69 | def fetch_markets(pg_config, user): |
69 | connection = psycopg2.connect(**pg_config) | 70 | connection = psycopg2.connect(**pg_config) |
@@ -109,6 +110,9 @@ def parse_args(argv): | |||
109 | parser.add_argument("--after", | 110 | parser.add_argument("--after", |
110 | default=False, action='store_const', const=True, | 111 | default=False, action='store_const', const=True, |
111 | help="Run the steps after the cryptoportfolio update") | 112 | help="Run the steps after the cryptoportfolio update") |
113 | parser.add_argument("--quiet", | ||
114 | default=False, action='store_const', const=True, | ||
115 | help="Don't print messages") | ||
112 | parser.add_argument("--debug", | 116 | parser.add_argument("--debug", |
113 | default=False, action='store_const', const=True, | 117 | default=False, action='store_const', const=True, |
114 | help="Run in debug mode") | 118 | help="Run in debug mode") |
@@ -131,7 +135,7 @@ def parse_args(argv): | |||
131 | def process(market_config, user_id, report_path, args): | 135 | def process(market_config, user_id, report_path, args): |
132 | try: | 136 | try: |
133 | market.Market\ | 137 | market.Market\ |
134 | .from_config(market_config, debug=args.debug, user_id=user_id, report_path=report_path)\ | 138 | .from_config(market_config, args, user_id=user_id, report_path=report_path)\ |
135 | .process(args.action, before=args.before, after=args.after) | 139 | .process(args.action, before=args.before, after=args.after) |
136 | except Exception as e: | 140 | except Exception as e: |
137 | print("{}: {}".format(e.__class__.__name__, e)) | 141 | print("{}: {}".format(e.__class__.__name__, e)) |