summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Wagner <bwgpro@gmail.com>2015-06-03 13:41:01 -0300
committerBruno Wagner <bwgpro@gmail.com>2015-06-03 13:41:01 -0300
commite67b2c523f0f343f8416b7ee4096deb117209301 (patch)
tree30b4e7856feab48b7becdd4446f48b39512cd67d
parentd11a2b8d66f77fa9a263e85d314dd7712702a605 (diff)
Moved all args parseing to config/args and fixed maintenance after the shifts
-rw-r--r--service/pixelated/config/args.py16
-rw-r--r--service/pixelated/maintenance.py36
2 files changed, 26 insertions, 26 deletions
diff --git a/service/pixelated/config/args.py b/service/pixelated/config/args.py
index a5d19369..f3549df1 100644
--- a/service/pixelated/config/args.py
+++ b/service/pixelated/config/args.py
@@ -18,7 +18,7 @@ import argparse
from pixelated.bitmask_libraries.config import DEFAULT_LEAP_HOME
-def parse():
+def parse_user_agent_args():
parser = argparse.ArgumentParser(description='Pixelated user agent.')
parser_add_default_arguments(parser)
@@ -33,6 +33,20 @@ def parse():
return args
+def parse_maintenance_args():
+ parser = argparse.ArgumentParser(description='pixelated maintenance')
+ parser_add_default_arguments(parser)
+ subparsers = parser.add_subparsers(help='commands', dest='command')
+ subparsers.add_parser('reset', help='reset account command')
+ mails_parser = subparsers.add_parser('load-mails', help='load mails into account')
+ mails_parser.add_argument('file', nargs='+', help='file(s) with mail data')
+
+ subparsers.add_parser('dump-soledad', help='dump the soledad database')
+ subparsers.add_parser('sync', help='sync the soledad database')
+
+ return parser.parse_args()
+
+
def parser_add_default_arguments(parser):
parser.add_argument('--debug', action='store_true', help='DEBUG mode.')
parser.add_argument('--dispatcher', help='run in organization mode, the credentials will be read from specified file', metavar='file')
diff --git a/service/pixelated/maintenance.py b/service/pixelated/maintenance.py
index 167a844a..22cc9cb9 100644
--- a/service/pixelated/maintenance.py
+++ b/service/pixelated/maintenance.py
@@ -18,18 +18,18 @@ import os
from functools import partial
import sys
import json
-import argparse
import email
import re
from os.path import join
from mailbox import mboxMessage, Maildir
-from pixelated.config.app import App
+from pixelated.config.config import Config
from pixelated.config import app_factory
-from pixelated.config.args import parser_add_default_arguments
+from pixelated.config.args import parse_maintenance_args
from pixelated.config.config_ua import config_user_agent
from pixelated.config.dispatcher import config_dispatcher
from pixelated.config.events_server import init_events_server
+from pixelated.config.initialize_leap import initialize_leap
from pixelated.config.loading_page import loading
from pixelated.config.register import register
from pixelated.config.logging_setup import init_logging
@@ -53,16 +53,16 @@ import pixelated.support.ext_requests_urllib3
def initialize():
- args = parse_args()
- app = App()
+ args = parse_maintenance_args()
+ app = Config()
- init_logging(args)
- init_leap_cert(args)
+ init_logging(debug=args.debug)
- if args.dispatcher or args.dispatcher_stdin:
- config_dispatcher(app, args)
- else:
- config_user_agent(app, args)
+ app = initialize_leap(args.leap_provider_cert,
+ args.leap_provider_cert_fingerprint,
+ args.config,
+ args.dispatcher,
+ args.dispatcher_stdin)
init_events_server()
execute_command = create_execute_command(args, app)
@@ -71,20 +71,6 @@ def initialize():
reactor.run()
-def parse_args():
- parser = argparse.ArgumentParser(description='pixelated maintenance')
- parser_add_default_arguments(parser)
- subparsers = parser.add_subparsers(help='commands', dest='command')
- subparsers.add_parser('reset', help='reset account command')
- mails_parser = subparsers.add_parser('load-mails', help='load mails into account')
- mails_parser.add_argument('file', nargs='+', help='file(s) with mail data')
-
- subparsers.add_parser('dump-soledad', help='dump the soledad database')
- subparsers.add_parser('sync', help='sync the soledad database')
-
- return parser.parse_args()
-
-
def create_execute_command(args, app):
def execute_command():