예제 #1
0
 def move_to_dest_dir(self):
     try:
         shutil.move(self.move_source, self.move_dest)
         if self.verbose:
             logger.info('extracted archive to {}.'.format(self.move_dest))
     except Exception as e:
         logger.error(e)
         msg = 'Moving the extracted data to \'{}\' failed.'
         raise PathError(msg.format(self.move_dest.decode('utf-8')))
예제 #2
0
 def _download_file(self, link, name):
     downloader = Downloader(link)
     try:
         downloader.retrieve()
     except tek.errors.NotEnoughDiskSpace as e:
         logger.error(e)
     else:
         state = 'complete' if downloader.success else 'failed'
         logger.info('')
         logger.info('Download {}: {}'.format(state, name))
예제 #3
0
 def _exec(self, cmdline, verbose):
     if verbose:
         logger.info('executing {}'.format(' '.join(cmdline)))
     if self.pipe:
         stdout = stderr = subprocess.PIPE
     else:
         stdout, stderr = sys.stdout, sys.stderr
     proc = subprocess.Popen(cmdline, stdout=stdout, stderr=stderr)
     self.exitval = proc.wait()
     if self.pipe:
         self.output = proc.stdout.readlines()
예제 #4
0
 def search(self, **kw):
     try:
         for i in itertools.count():
             try:
                 data = self._request(i, **kw).content
                 for url in self._extract_urls(data):
                     yield url
             except requests.Timeout:
                 logger.warn('Timeout in search!')
     except (requests.RequestException, NoMoreResults) as e:
         logger.info('Search aborted: {}'.format(e))
예제 #5
0
 def retrieve(self):
     forever = self._retry < 0
     tries = self._retry
     retry = lambda: forever or tries >= 0
     while retry():
         tries -= 1
         try:
             self._prepare()
             return self._transfer()
         except (RequestException, socket.timeout) as e:
             action = 'Retrying in 5 seconds.' if retry() else 'Aborting.'
             logger.warning('Connection error: {}!'.format(e))
             logger.info(action)
             if retry():
                 time.sleep(5)
예제 #6
0
 def _wait_for_files(self):
     if not self._files and self._uris:
         logger.info('Files not synced yet. Waiting for 5 seconds.')
         time.sleep(5)
     return bool(self._files)
예제 #7
0
 def add_command(self, cmd):
     """ run iptables process with given args """
     assert (isinstance(cmd, Command))
     logger.info(cmd.string)
     self.commands.append(cmd)
예제 #8
0
파일: cpu.py 프로젝트: yangyang202/DA_GP9
 def __exit__(self, exc_type, exc_val, exc_tb):
     self._end = self._current
     if self._log and self.enabled:
         logger.info('{}: {}s'.format(self._label, self.time))
예제 #9
0
파일: __init__.py 프로젝트: tek/pytek
 def print_all(self):
     logger.info(self._config.info)