Example #1
0
    def run_dev_tools_script(self):

        log.info('Running Dev Tools initialization script.')
        current_path = os.getcwd()

        try:
            if misc.is_os_windows():
                path = self._climb_dir_tree(misc.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))
                self._call([OSSpecific.WindowsModuleScriptName])

                log.debug('Changing path to {0}.'.format(current_path))
                os.chdir(current_path)

                log.info('Running script "{0}".'.format(
                    OSSpecific.WindowsRepoScript))
                self._call([os.path.join(path, OSSpecific.WindowsRepoScript)])
            else:
                path = self._climb_dir_tree(misc.ori_path(),
                                            OSSpecific.LinuxClimbUpDepth)
                log.info('Running script "{0}" at {1}.'.format(
                    OSSpecific.LinuxRepoScript, path))
                self._call([os.path.join(path, OSSpecific.LinuxRepoScript)])

        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)
            raise
Example #2
0
    def run_dev_tools_script(self):

        log.info('Running Dev Tools initialization script.')
        current_path = os.getcwd()
        
        try:
            if misc.is_os_windows():
                path = self._climb_dir_tree(misc.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))
                self._call([OSSpecific.WindowsModuleScriptName])
                
                log.debug('Changing path to {0}.'.format(current_path))
                os.chdir(current_path)
                
                log.info('Running script "{0}".'.format(OSSpecific.WindowsRepoScript))
                self._call([os.path.join(path, OSSpecific.WindowsRepoScript)])
            else:
                path = self._climb_dir_tree(misc.ori_path(), OSSpecific.LinuxClimbUpDepth)
                log.info('Running script "{0}" at {1}.'.format(OSSpecific.LinuxRepoScript,
                                                                path))
                self._call([os.path.join(path, OSSpecific.LinuxRepoScript)])
                
        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)
            raise
Example #3
0
    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(
                                        misc.ori_path(), CABundle.Path,
                                        CABundle.Name))
Example #4
0
    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(misc.ori_path(),
                                                            CABundle.Path,
                                                            CABundle.Name))
Example #5
0
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 = misc.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)
Example #6
0
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:
        config_file.create_directory(spec_dir)
        output_file = spec_dir + os.path.sep + filename

    ori_path = misc.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)
Example #7
0
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:
        config_file.create_directory(spec_dir)
        output_file = spec_dir + os.path.sep + filename
        
    ori_path = misc.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)
Example #8
0
def where():
    return   os.path.join(misc.ori_path(), CABundle.Path, CABundle.Name)