本文整理汇总了Python中Configuration.Configuration.refresh方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.refresh方法的具体用法?Python Configuration.refresh怎么用?Python Configuration.refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.refresh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: YoutubeDownloader
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import refresh [as 别名]
class YoutubeDownloader(multiprocessing.Process):
def __init__(self, work_queue, result_queue):
global doDebug
# base class initialization
multiprocessing.Process.__init__(self)
self.name = os.path.basename(os.path.abspath("."))
self.__config = Configuration(self.name)
# job management stuff
self.work_queue = work_queue
self.result_queue = result_queue
self.kill_received = False
def run(self):
global doDebug
while not self.kill_received:
if doDebug:
print "check for next url"
try:
url = self.work_queue.get()
self.__config.refresh()
videos_directory = self.__config.get('Configuration', 'videos_directory')
self.useFormat = self.__config.get('Download Options', 'useFormat')
self.videoFormat = self.__config.get('Download Options', 'videoFormat')
self.maxVideoFormat = self.__config.get('Download Options', 'maxVideoFormat')
self.useAuthentication = self.__config.get('Download Options', 'useAuthentication')
self.userName = self.__config.get('Download Options', 'userName')
self.userPassword = self.__config.get('Download Options', 'userPassword')
self.ignoreErrors = self.__config.get('Download Options', 'ignoreErrors')
self.resumeDownload = self.__config.get('Download Options', 'resumeDownload')
self.noOverwrites = self.__config.get('Download Options', 'noOverwrites')
self.useTitle = self.__config.get('Download Options', 'useTitle')
if not videos_directory:
p = subprocess.Popen(["xdg-user-dir","VIDEOS"],stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=False)
directoryName, errors = p.communicate()
directoryName=directoryName.rstrip()
videos_directory = os.path.abspath(directoryName)
if not (videos_directory == os.path.abspath('.')):
os.chdir(videos_directory)
if doDebug:
print "current video directory is: "+os.path.abspath('.')
retcode = self.main(url)
except Queue.Empty:
time.sleep(1)
def debug(self):
global doDebug
doDebug = True
def main(self,url):
global doDebug
if doDebug:
print "In main URL is: "+url
parser, opts, args = parseOpts()
#Need to set user options from config file if we can
if self.useFormat == '0':
opts.format = youtube.videoFormats.get(self.videoFormat)
elif self.useFormat == '1':
opts.format_limit = youtube.videoFormats.get(self.maxVideoFormat)
if self.useAuthentication == '1':
opts.username = self.userName
opts.password = self.userPassword
opts.continue_dl = self.resumeDownload
opts.ignoreerrors = self.ignoreErrors
opts.nooverwrites = self.noOverwrites
opts.usetitle = self.useTitle
# Open appropriate CookieJar
if opts.cookiefile is None:
jar = cookielib.CookieJar()
else:
try:
jar = cookielib.MozillaCookieJar(opts.cookiefile)
if os.path.isfile(opts.cookiefile) and os.access(opts.cookiefile, os.R_OK):
jar.load()
except (IOError, OSError), err:
time.sleep(1)
# Dump user agent
if opts.dump_user_agent:
print std_headers['User-Agent']
# Batch file verification
batchurls = []
if opts.batchfile is not None:
try:
if opts.batchfile == '-':
batchfd = sys.stdin
else:
batchfd = open(opts.batchfile, 'r')
batchurls = batchfd.readlines()
batchurls = [x.strip() for x in batchurls]
batchurls = [x for x in batchurls if len(x) > 0 and not re.search(r'^[#/;]', x)]
except IOError:
time.s;eep(1)
all_urls = batchurls
#.........这里部分代码省略.........