def execute(self, pool): # Test if git local repo exists if not os.path.isdir(os.path.join(os.getcwdu(), DevToolsConfigFile.Path)): prompt.error(DevToolsMessage.GitRepoNotExist.format('')) return error = False current_path = os.getcwdu() try: log.info(u'Running Dev Tools initialization script.') if misc.is_os_windows(): path = shell_utils.climb_dir_tree(shell_utils.ori_path(), OSSpecific.WindowsClimbUpDepth) #TODO: replace current workaround for WindowsModuleScript current_path = os.getcwdu() script_path = os.path.join(path, OSSpecific.WindowsModuleScriptPath) log.debug(u'Changing path to {0}.'.format(script_path)) os.chdir(script_path) log.info(u'Running script "{0}".'.format(OSSpecific.WindowsModuleScriptName)) shell_utils.call([OSSpecific.WindowsModuleScriptName]) log.debug(u'Changing path to {0}.'.format(current_path)) os.chdir(current_path) log.info(u'Running script "{0}".'.format(OSSpecific.WindowsRepoScript)) fullpath = os.path.join(path, OSSpecific.WindowsRepoScript) prompt.error(shell_utils.call([fullpath])) else: path = shell_utils.climb_dir_tree(shell_utils.ori_path(), OSSpecific.LinuxClimbUpDepth) log.info(u'Running script "{0}" at {1}.'.format(OSSpecific.LinuxRepoScript, path)) fullpath = os.path.join(path, OSSpecific.LinuxRepoScript) prompt.error(shell_utils.call([fullpath])) location = DevToolsConfigFile.Path + os.path.sep + DevToolsConfigFile.Name config_file.set_access_permission(location, True) except subprocess.CalledProcessError as ex: # Git returned with an error code log.error(u'Dev Tools initialization script report an error, because "{0}".'.format(ex)) error = True prompt.error(DevToolsMessage.InitError.format(ex.message)) except (OSError, IOError) as ex: log.error(u'Failed to call Dev Tools initialization script, because "{0}".'.format(ex)) # Cannot find or run script error = True if ex.errno == FileErrorConstant.FileNotFoundErrorCode: if fullpath: prompt.error(DevToolsMessage.FileMissingError.format(fullpath)) else: prompt.error(ex) finally: if error: prompt.error(DevToolsMessage.ExecutionError.format(DevToolsConfigFile.InitHelpUrl)) ret_result = OperationResult(self, None, None, None) return ret_result
def run_dev_tools_script(self): log.info('Running Dev Tools initialization script.') current_path = os.getcwd() try: if misc.is_os_windows(): path = shell_utils.climb_dir_tree( shell_utils.ori_path(), OSSpecific.WindowsClimbUpDepth) #TODO: replace current workaround for WindowsModuleScript current_path = os.getcwd() script_path = os.path.join(path, OSSpecific.WindowsModuleScriptPath) log.debug('Changing path to {0}.'.format(script_path)) os.chdir(script_path) log.info('Running script "{0}".'.format( OSSpecific.WindowsModuleScriptName)) shell_utils.call([OSSpecific.WindowsModuleScriptName]) log.debug('Changing path to {0}.'.format(current_path)) os.chdir(current_path) log.info('Running script "{0}".'.format( OSSpecific.WindowsRepoScript)) fullpath = os.path.join(path, OSSpecific.WindowsRepoScript) shell_utils.call([fullpath]) else: path = shell_utils.climb_dir_tree(shell_utils.ori_path(), OSSpecific.LinuxClimbUpDepth) log.info('Running script "{0}" at {1}.'.format( OSSpecific.LinuxRepoScript, path)) fullpath = os.path.join(path, OSSpecific.LinuxRepoScript) shell_utils.call([fullpath]) except subprocess.CalledProcessError as ex: # Git returned with an error code log.error( 'Dev Tools initialiation script report an error, because "{0}".' .format(ex)) prompt.error(DevToolsMessage.InitError) raise except (OSError, IOError) as ex: log.error( 'Failed to call Dev Tools initialiation script, because "{0}".' .format(ex)) # Cannot find or run script if ex.errno == FileErrorConstant.FileNotFoundErrorCode: prompt.error(DevToolsMessage.FileMissingError.format(fullpath)) raise
def run_dev_tools_script(self): log.info('Running Dev Tools initialization script.') current_path = os.getcwd() try: if misc.is_os_windows(): path = shell_utils.climb_dir_tree(shell_utils.ori_path(), OSSpecific.WindowsClimbUpDepth) #TODO: replace current workaround for WindowsModuleScript current_path = os.getcwd() script_path = os.path.join(path, OSSpecific.WindowsModuleScriptPath) log.debug('Changing path to {0}.'.format(script_path)) os.chdir(script_path) log.info('Running script "{0}".'.format(OSSpecific.WindowsModuleScriptName)) shell_utils.call([OSSpecific.WindowsModuleScriptName]) log.debug('Changing path to {0}.'.format(current_path)) os.chdir(current_path) log.info('Running script "{0}".'.format(OSSpecific.WindowsRepoScript)) fullpath = os.path.join(path, OSSpecific.WindowsRepoScript) shell_utils.call([fullpath]) else: path = shell_utils.climb_dir_tree(shell_utils.ori_path(), OSSpecific.LinuxClimbUpDepth) log.info('Running script "{0}" at {1}.'.format(OSSpecific.LinuxRepoScript, path)) fullpath = os.path.join(path, OSSpecific.LinuxRepoScript) shell_utils.call([fullpath]) except subprocess.CalledProcessError as ex: # Git returned with an error code log.error('Dev Tools initialiation script report an error, because "{0}".'.format(ex)) prompt.error(DevToolsMessage.InitError) raise except (OSError, IOError) as ex: log.error('Failed to call Dev Tools initialiation script, because "{0}".'.format(ex)) # Cannot find or run script if ex.errno == FileErrorConstant.FileNotFoundErrorCode: prompt.error(DevToolsMessage.FileMissingError.format(fullpath)) raise
def connect(self): sock = socket.create_connection((self.host, self.port), self.timeout, self.source_address) if self._tunnel_host: self.sock = sock self._tunnel() self.sock = ssl.wrap_socket( sock, ssl_version=ssl.PROTOCOL_TLSv1, cert_reqs=ssl.CERT_REQUIRED, ca_certs=os.path.join(shell_utils.ori_path(), CABundle.Path, CABundle.Name), )
def connect(self): sock = socket.create_connection((self.host, self.port), self.timeout, self.source_address) if self._tunnel_host: self.sock = sock self._tunnel() self.sock = ssl.wrap_socket(sock, ssl_version = ssl.PROTOCOL_TLSv1, cert_reqs = ssl.CERT_REQUIRED, ca_certs = os.path.join(shell_utils.ori_path(), CABundle.Path, CABundle.Name))
def configureLogging(level=None, quiet=False, filename=EbLogFile.Name, spec_dir=os.getcwd() + os.path.sep + EbLocalDir.Path): if not spec_dir: output_file = _getLogFile(filename) else: config_file.create_directory(spec_dir) output_file = spec_dir + os.path.sep + filename ori_path = shell_utils.ori_path() log_config_location = os.path.join(ori_path, 'logconfig.json') try: with codecs.open(log_config_location, 'r', encoding='utf-8') as input_file: config_dict = json.loads(input_file.read()) _set_log_filename(config_dict, output_file) if level is None and config_dict['root']['level'].upper() == 'NONE': # completely disable log config_dict['root']['level'] = 'NOTSET' _disable_logging(config_dict) else: if level is not None: config_dict['root']['level'] = level _set_log_handlers(config_dict, 'default') except (IOError, ValueError, KeyError) as ex: #JSON logging config file parsing error if not quiet: print(('Encountered error when reading logging configuration file from "{0}": {1}.'.\ format(log_config_location, ex))) _disable_logging() return try: _config.dictConfig(config_dict) except IOError: if not quiet: print('Could not open {0} for logging. Using stderr instead.'.\ format(output_file), file=sys.stderr) _set_log_handlers(config_dict, 'to_stderr') _config.dictConfig(config_dict) config_file.set_access_permission(output_file, True)
def configureLogging(level = None, quiet = False, filename = EbLogFile.Name, spec_dir = os.getcwdu() + os.path.sep + EbLocalDir.Path): if not spec_dir: output_file=_getLogFile(filename) else: shell_utils.create_directory(spec_dir) output_file = spec_dir + os.path.sep + filename ori_path = shell_utils.ori_path() log_config_location = os.path.join(ori_path, u'logconfig.json') try: with codecs.open(log_config_location, 'r', encoding='utf-8') as input_file: config_dict = json.loads(input_file.read()) _set_log_filename(config_dict, output_file) if level is None and config_dict[u'root'][u'level'].upper() == u'NONE': # completely disable log config_dict[u'root'][u'level'] = u'NOTSET' _disable_logging(config_dict) else: if level is not None: config_dict[u'root'][u'level'] = level _set_log_handlers(config_dict, u'default') except (IOError, ValueError, KeyError) as ex: #JSON logging config file parsing error if not quiet: print(u'Encountered error when reading logging configuration file from "{0}": {1}.'.\ format(log_config_location, ex)) _disable_logging() return try: _config.dictConfig(config_dict) except IOError: if not quiet: print >> sys.stderr, u'Could not open {0} for logging. Using stderr instead.'.\ format(output_file) _set_log_handlers(config_dict, u'to_stderr') _config.dictConfig(config_dict) config_file.set_access_permission(output_file, True)
def where(): """Return the preferred certificate bundle.""" # vendored bundle inside Requests return os.path.join(shell_utils.ori_path(), CABundle.Path, CABundle.Name)
def where(): """Return the preferred certificate bundle.""" # vendored bundle inside Requests return os.path.join(shell_utils.ori_path(), CABundle.Path, CABundle.Name)
def where(): return os.path.join(shell_utils.ori_path(), CABundle.Path, CABundle.Name)