当前位置: 首页>>代码示例>>Python>>正文


Python Config.redataproduct方法代码示例

本文整理汇总了Python中config.config.Config.redataproduct方法的典型用法代码示例。如果您正苦于以下问题:Python Config.redataproduct方法的具体用法?Python Config.redataproduct怎么用?Python Config.redataproduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在config.config.Config的用法示例。


在下文中一共展示了Config.redataproduct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import redataproduct [as 别名]

#.........这里部分代码省略.........
            errlist         = []            # list of failed download targets.
            should_finish   = False

            logfile = ''
            try:
                logfile = open(logfilename)
            except IOError as e:
                print e;

            # for individual file download checks, scan through the "noise" in the file,
            # looking for typical download start/end signatures, taking note of those that
            # are incomplete:

            for line in logfile:

                # timestamp and target request match?
                if self.timestamp_and_target.match(line):
                    should_finish = True

                #if timestamp_and_target.match(line) and not get_request.search(line):
                    tt_match_this_line=True
                    if tt_match:
                        tt_match_prev = tt_match
                    tt_match = self.timestamp_and_target.match(line)

                # "saved" string match?
                saved_match = self.saved.search(line)

                # check process status:
                if tt_match_this_line and not downloading:
                    # start of new request
                    downloading = True
                elif tt_match_this_line and downloading and \
                     tt_match.group(1)!=tt_match_prev.group(1):
                    # new download request without successful completion of prior one
                    # (sometimes wget attempts to re-download a target, which is perfectly
                    # ok, thus the check against the previous target)
                    err = True
                elif downloading and saved_match:
                    # successful completion; reset logicals
                    downloading = False
                    saved_match = None
                    self.download_list.append('\'' + tt_match.group(1) + '\'')
                    self.saved_file_locs.append(re.search(self.regex_save_loc, line).group(1))
                elif self.finished.match(line):
                    _finished_  = True
                elif self.regex_saved_file_loc.search(line):
                    if ".listing" not in self.regex_saved_file_loc.search(line).group(1):
                        self.saved_file_locs.append(self.regex_saved_file_loc.search(line).group(1))
                elif self.regex_unreachable_network.search(line):
                    self.summary += 'Unable to connect, network is unreachable.\n'

                if err:
                    # capture target of failed request
                    errlist.append(tt_match_prev.group(1))

                # continue download error search:
                err = False
                tt_match_this_line = False

            # last attempted download complete?:
            if should_finish and not _finished_:
                try:
                    errlist.append('download aborted during read of '+tt_match.group(1))
                except:
                    errlist.append('download aborted.')

            self.summary += '\nlog file at: ' + logfilename + '\n\n'

            # summary output:
            if errlist.__len__():
                print '%s:' % logfilename
                print '   error(s) downloading the following files in the collection:'
                for failed_target in errlist:
                    print '   %s' % failed_target

            if len(self.saved_file_locs) > 0:
                mo = re.search(self.config.redataproduct(), logfilename)
                download_size = 0
                isPrecon = mo and mo.group(1) in self.config.preconwatch() # check if this logfile is monitored for precon processing
                for f in self.saved_file_locs:
                    f = f.replace("'", "")
                    download_size += os.path.getsize(f) # remove single quotes
                    if isPrecon:
                        precon.write(f + '\n')
                self.summary += 'files downloaded: ' + str(len(self.saved_file_locs)) + '\n'
                self.summary += 'total download size: ' + str(download_size/1000000000.0) + ' GB\n'
                self.summary += 'saved to location: ' + re.search('/.*/', self.saved_file_locs[0][1:-1]).group() + '\n'
            else:
                self.summary += 'no files downloaded\n'
            
            del self.download_list[:]
            del self.saved_file_locs[:]

            self.summary += '\n*******************************************************************************************************\n\n'

        precon.close()
        # if nothing was written, delete empty file
        if os.path.getsize(self.config.preconfilename()) == 0:
            os.remove(self.config.preconfilename())
开发者ID:munizas,项目名称:datafetchpipeline,代码行数:104,代码来源:wgetlogvalidator.py


注:本文中的config.config.Config.redataproduct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。