summaryrefslogtreecommitdiffstats
path: root/scripts/devtool
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/devtool')
-rwxr-xr-xscripts/devtool19
1 files changed, 9 insertions, 10 deletions
diff --git a/scripts/devtool b/scripts/devtool
index 60ea3e8298..acc4e0e982 100755
--- a/scripts/devtool
+++ b/scripts/devtool
@@ -13,10 +13,8 @@ import argparse
13import glob 13import glob
14import re 14import re
15import configparser 15import configparser
16import subprocess
17import logging 16import logging
18 17
19basepath = ''
20workspace = {} 18workspace = {}
21config = None 19config = None
22context = None 20context = None
@@ -33,13 +31,15 @@ logger = scriptutils.logger_create('devtool')
33plugins = [] 31plugins = []
34 32
35 33
36class ConfigHandler(object): 34class ConfigHandler:
35 basepath = None
37 config_file = '' 36 config_file = ''
38 config_obj = None 37 config_obj = None
39 init_path = '' 38 init_path = ''
40 workspace_path = '' 39 workspace_path = ''
41 40
42 def __init__(self, filename): 41 def __init__(self, basepath, filename):
42 self.basepath = basepath
43 self.config_file = filename 43 self.config_file = filename
44 self.config_obj = configparser.ConfigParser() 44 self.config_obj = configparser.ConfigParser()
45 45
@@ -59,14 +59,14 @@ class ConfigHandler(object):
59 59
60 if self.config_obj.has_option('General', 'init_path'): 60 if self.config_obj.has_option('General', 'init_path'):
61 pth = self.get('General', 'init_path') 61 pth = self.get('General', 'init_path')
62 self.init_path = os.path.join(basepath, pth) 62 self.init_path = os.path.join(self.basepath, pth)
63 if not os.path.exists(self.init_path): 63 if not os.path.exists(self.init_path):
64 logger.error('init_path %s specified in config file cannot be found' % pth) 64 logger.error('init_path %s specified in config file cannot be found' % pth)
65 return False 65 return False
66 else: 66 else:
67 self.config_obj.add_section('General') 67 self.config_obj.add_section('General')
68 68
69 self.workspace_path = self.get('General', 'workspace_path', os.path.join(basepath, 'workspace')) 69 self.workspace_path = self.get('General', 'workspace_path', os.path.join(self.basepath, 'workspace'))
70 return True 70 return True
71 71
72 72
@@ -86,7 +86,7 @@ class Context:
86 self.__dict__.update(kwargs) 86 self.__dict__.update(kwargs)
87 87
88 88
89def read_workspace(): 89def read_workspace(basepath):
90 global workspace 90 global workspace
91 workspace = {} 91 workspace = {}
92 if not os.path.exists(os.path.join(config.workspace_path, 'conf', 'layer.conf')): 92 if not os.path.exists(os.path.join(config.workspace_path, 'conf', 'layer.conf')):
@@ -209,7 +209,6 @@ def _enable_workspace_layer(workspacedir, config, basepath):
209 209
210 210
211def main(): 211def main():
212 global basepath
213 global config 212 global config
214 global context 213 global context
215 214
@@ -264,7 +263,7 @@ def main():
264 263
265 logger.debug('Using basepath %s' % basepath) 264 logger.debug('Using basepath %s' % basepath)
266 265
267 config = ConfigHandler(os.path.join(basepath, 'conf', 'devtool.conf')) 266 config = ConfigHandler(basepath, os.path.join(basepath, 'conf', 'devtool.conf'))
268 if not config.read(): 267 if not config.read():
269 return -1 268 return -1
270 context.config = config 269 context.config = config
@@ -332,7 +331,7 @@ def main():
332 331
333 try: 332 try:
334 if not getattr(args, 'no_workspace', False): 333 if not getattr(args, 'no_workspace', False):
335 read_workspace() 334 read_workspace(basepath)
336 335
337 ret = args.func(args, config, basepath, workspace) 336 ret = args.func(args, config, basepath, workspace)
338 except DevtoolError as err: 337 except DevtoolError as err: