Alexander Shorin avatar Alexander Shorin committed 8edd11b

Prepare config before app starts.

Comments (0)

Files changed (1)

         'loggers': {
             '__self__': {
                 'handlers': [],
-                'level': 'DEBUG'}
+                'level': 'DEBUG'
+            }
         },
         'root': {
             'handlers': [],
 
     def prepare(self):
         self.prepare_argparser()
+        if not sys.argv[1:]:
+            sys.argv[1:] = ['run', '-c',
+                            os.path.join(os.path.dirname(sys.argv[0]),
+                                         'config.ini')]
+        if sys.argv[1].startswith('-') and sys.argv[1] != '--help':
+            sys.argv.insert(1, 'run')
+        self.args, unknown = self.argparser.parse_known_args()
+        self.prepare_config()
 
     def prepare_argparser(self):
         self.argparser.add_argument(
             default=os.path.join(os.path.dirname(sys.argv[0]), 'config.ini'),
             help='Define config file with CouchDB credentials.')
 
-    def setup_config(self):
+    def prepare_config(self):
         if self.args and 'config' in self.args:
             self.config = self.config_loader.load_from_cfg(
                 self.args.config, self.name, defaults=self.config)
 
     def setup(self):
-        if not sys.argv[1:]:
-            sys.argv[1:] = ['run', '-c',
-                            os.path.join(os.path.dirname(sys.argv[0]),
-                                         'config.ini')]
-        if sys.argv[1].startswith('-') and sys.argv[1] != '--help':
-            sys.argv.insert(1, 'run')
-        self.args, unknown = self.argparser.parse_known_args()
-        self.setup_config()
         self.setup_logging()
 
     def setup_logging(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.