def get_locals(cls): """List local modules directory""" local_path = "%s/%s" % (utils.get_project_root(), utils.LOCAL_MODULES_DIRECTORY) return [f for f in listdir(local_path) if isfile(join(local_path, f))]
def get_locals(cls): """List 'local_modules' directory""" local_path = "%s/local_modules" % utils.get_project_root() return [f for f in listdir(local_path) if isfile(join(local_path, f))]
def main(): """Main loop""" rtn = 0 # First, lets make sure dtf has the dependencies we want. if check_dependencies() != 0: return -2 # If this is first run, we need to do a couple of things. # Note: I exit here; doesn't matter what you tried to run. if is_first_run(): sys.exit(do_first_run_process()) # Next, check args. if len(sys.argv) < 2: sys.exit(usage()) # Remove the execute path sys.argv.pop(0) # Remove and store cmd_name command_name = sys.argv.pop(0) # Help menu if command_name in ['-h', '--help', 'help']: sys.exit(usage_full()) # Version information elif command_name in ['-v', '--version', 'version']: sys.exit(print_version(sys.argv)) # Almost all commands with dtf require you to be in a project directory, # but some don't. Check for those next. elif command_name == 'pm': return pkg.launch_builtin_module('pm', sys.argv, chdir=False, skip_checks=True) elif command_name in ['init', 'binding', 'upgrade']: return pkg.launch_builtin_module(command_name, sys.argv, skip_checks=True) # Ok, now we need to get to the top of the project directory. project_root = utils.get_project_root() if project_root is None: log.e(TAG, "Unable to find a project root! Is this a dtf project?") return -3 # Next, we check the following: # 1. Is it a built-in command? # 2. Is it a local module? # 3. Is it a module we know about? if find_built_in_module(command_name): rtn = pkg.launch_builtin_module(command_name, sys.argv) elif pkg.find_local_module(project_root, command_name): rtn = pkg.launch_local_module(project_root, command_name, sys.argv) elif pkg.is_module_installed(command_name): rtn = pkg.launch_module(command_name, sys.argv) else: log.e(TAG, "Module or command '%s' not found!" % command_name) rtn = -4 return rtn
LOG_LEVEL_FILE = 4 # By default, log E-V LOG_LEVEL_STDOUT = 4 # By default, log E-V # Internals ########################################################### LOG_FILE_NAME = ".dtflog" LOG_FILE = None # Terminal Coloring COLOR_ERR = fg("#d70000") COLOR_WARN = fg("#d75f00") COLOR_INFO = fg("#00d700") COLOR_VERB = fg("#00d7ff") COLOR_DEB = fg("#d700af") # Open file on module import TOP = utils.get_project_root() if TOP is not None: LOG_FILE = open(LOG_FILE_NAME, "a") def __get_date(): """Format current date""" return strftime("%a %b %d %H:%M:%S %Z %Y", localtime()) def __log(buf, entry): """Low level print function"""
LOG_LEVEL_FILE = 4 # By default, log E-V LOG_LEVEL_STDOUT = 4 # By default, log E-V # Internals ########################################################### LOG_FILE_NAME = '.dtflog' LOG_FILE = None # Terminal Coloring COLOR_ERR = fg('#d70000') COLOR_WARN = fg('#d75f00') COLOR_INFO = fg('#00d700') COLOR_VERB = fg('#00d7ff') COLOR_DEB = fg('#d700af') # Open file on module import TOP = utils.get_project_root() if TOP is not None: LOG_FILE = open(LOG_FILE_NAME, 'a') def __get_date(): """Format current date""" return strftime("%a %b %d %H:%M:%S %Z %Y", localtime()) def __log(buf, entry): """Low level print function""" buf.write(entry)