本文整理汇总了Python中mylar.logger.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shutdown
def shutdown(restart=False, update=False):
cherrypy.engine.exit()
halt()
if not restart and not update:
logger.info('Mylar is shutting down...')
if update:
logger.info('Mylar is updating...')
try:
versioncheck.update()
except Exception as e:
logger.warn('Mylar failed to update: %s. Restarting.' % e)
if CREATEPID:
logger.info('Removing pidfile %s' % PIDFILE)
os.remove(PIDFILE)
if restart:
logger.info('Mylar is restarting...')
popen_list = [sys.executable, FULL_PATH]
popen_list += ARGS
# if '--nolaunch' not in popen_list:
# popen_list += ['--nolaunch']
logger.info('Restarting Mylar with ' + str(popen_list))
subprocess.Popen(popen_list, cwd=os.getcwd())
os._exit(0)
示例2: torsend2client
def torsend2client(seriesname, linkit, site):
logger.info('matched on ' + str(seriesname))
filename = re.sub('[\'\!\@\#\$\%\:\;\/\\=\?\.]', '',seriesname)
if site == 'ComicBT':
logger.info(linkit)
linkit = str(linkit) + '&passkey=' + str(mylar.CBT_PASSKEY)
if linkit[-7:] != "torrent":
filename += ".torrent"
request = urllib2.Request(linkit)
request.add_header('User-Agent', str(mylar.USER_AGENT))
if mylar.TORRENT_LOCAL and mylar.LOCAL_WATCHDIR is not None:
filepath = os.path.join(mylar.LOCAL_WATCHDIR, filename)
logger.fdebug('filename for torrent set to : ' + filepath)
elif mylar.TORRENT_SEEDBOX and mylar.SEEDBOX_WATCHDIR is not None:
filepath = os.path.join(mylar.CACHE_DIR, filename)
logger.fdebug('filename for torrent set to : ' + filepath)
else:
logger.error('No Local Watch Directory or Seedbox Watch Directory specified. Set it and try again.')
return "fail"
try:
opener = helpers.urlretrieve(urllib2.urlopen(request), filepath)
except Exception, e:
logger.warn('Error fetching data from %s: %s' % (site, e))
return "fail"
示例3: halt
def halt():
global _INITIALIZED, started
with INIT_LOCK:
if _INITIALIZED:
logger.info('Shutting down the background schedulers...')
SCHED.shutdown(wait=False)
if NZBPOOL is not None:
logger.info('Terminating the nzb auto-complete thread.')
try:
NZBPOOL.join(10)
logger.info('Joined pool for termination - successful')
except KeyboardInterrupt:
NZB_QUEUE.put('exit')
NZBPOOL.join(5)
except AssertionError:
os._exit(0)
if SNPOOL is not None:
logger.info('Terminating the auto-snatch thread.')
try:
SNPOOL.join(10)
logger.info('Joined pool for termination - successful')
except KeyboardInterrupt:
SNATCHED_QUEUE.put('exit')
SNPOOL.join(5)
except AssertionError:
os._exit(0)
_INITIALIZED = False
示例4: downloadfile
def downloadfile(self, payload, filepath):
url = 'https://32pag.es/torrents.php'
try:
r = self.session.get(url, params=payload, verify=True, stream=True, allow_redirects=True)
except Exception as e:
logger.error('%s [%s] Could not POST URL %s' % ('[32P-DOWNLOADER]', e, url))
return False
if str(r.status_code) != '200':
logger.warn('Unable to download torrent from 32P [Status Code returned: %s]' % r.status_code)
if str(r.status_code) == '404' and site == '32P':
logger.warn('[32P-CACHED_ENTRY] Entry found in 32P cache - incorrect. Torrent has probably been merged into a pack, or another series id. Removing from cache.')
helpers.delete_cache_entry(linkit)
else:
logger.info('content: %s' % r.content)
return False
with open(filepath, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.flush()
return True
示例5: notify
def notify(self, text, attachment_text, snatched_nzb=None, prov=None, sent_to=None, module=None):
if module is None:
module = ''
module += '[NOTIFIER]'
if all([sent_to is not None, prov is not None]):
attachment_text += ' from %s and %s' % (prov, sent_to)
elif sent_to is None:
attachment_text += ' from %s' % prov
else:
pass
payload = {
# "text": text,
# "attachments": [
# {
# "color": "#36a64f",
# "text": attachment_text
# }
# ]
# FIX: #1861 move notif from attachment to msg body - bbq
"text": attachment_text
}
try:
response = requests.post(self.webhook_url, json=payload, verify=True)
except Exception, e:
logger.info(module + u'Slack notify failed: ' + str(e))
示例6: comic_config
def comic_config(self, com_location, ComicID, alt_search=None, fuzzy_year=None):
myDB = db.DBConnection()
#--- this is for multipe search terms............
#--- works, just need to redo search.py to accomodate multiple search terms
# ffs_alt = []
# if '+' in alt_search:
#find first +
# ffs = alt_search.find('+')
# ffs_alt.append(alt_search[:ffs])
# ffs_alt_st = str(ffs_alt[0])
# print("ffs_alt: " + str(ffs_alt[0]))
# split the entire string by the delimter +
# ffs_test = alt_search.split('+')
# if len(ffs_test) > 0:
# print("ffs_test names: " + str(len(ffs_test)))
# ffs_count = len(ffs_test)
# n=1
# while (n < ffs_count):
# ffs_alt.append(ffs_test[n])
# print("adding : " + str(ffs_test[n]))
#print("ffs_alt : " + str(ffs_alt))
# ffs_alt_st = str(ffs_alt_st) + "..." + str(ffs_test[n])
# n+=1
# asearch = ffs_alt
# else:
# asearch = alt_search
asearch = str(alt_search)
controlValueDict = {'ComicID': ComicID}
newValues = {"ComicLocation": com_location }
#"QUALalt_vers": qual_altvers,
#"QUALScanner": qual_scanner,
#"QUALtype": qual_type,
#"QUALquality": qual_quality
#}
if asearch is not None:
if asearch == '':
newValues['AlternateSearch'] = "None"
else:
newValues['AlternateSearch'] = str(asearch)
if fuzzy_year is None:
newValues['UseFuzzy'] = "0"
else:
newValues['UseFuzzy'] = str(fuzzy_year)
#force the check/creation of directory com_location here
if os.path.isdir(str(com_location)):
logger.info(u"Validating Directory (" + str(com_location) + "). Already exists! Continuing...")
else:
logger.fdebug("Updated Directory doesn't exist! - attempting to create now.")
try:
os.makedirs(str(com_location))
logger.info(u"Directory successfully created at: " + str(com_location))
except OSError:
logger.error(u"Could not create comicdir : " + str(com_location))
myDB.upsert("comics", newValues, controlValueDict)
raise cherrypy.HTTPRedirect("artistPage?ComicID=%s" % ComicID)
示例7: deleteArtist
def deleteArtist(self, ComicID):
myDB = db.DBConnection()
comic = myDB.action('SELECT * from comics WHERE ComicID=?', [ComicID]).fetchone()
logger.info(u"Deleting all traces of Comic: " + comic['ComicName'])
myDB.action('DELETE from comics WHERE ComicID=?', [ComicID])
myDB.action('DELETE from issues WHERE ComicID=?', [ComicID])
raise cherrypy.HTTPRedirect("home")
示例8: versionload
def versionload():
mylar.CURRENT_VERSION, mylar.CONFIG.GIT_BRANCH = getVersion()
if mylar.CURRENT_VERSION is not None:
hash = mylar.CURRENT_VERSION[:7]
else:
hash = "unknown"
if mylar.CONFIG.GIT_BRANCH == 'master':
vers = 'M'
elif mylar.CONFIG.GIT_BRANCH == 'development':
vers = 'D'
else:
vers = 'NONE'
mylar.USER_AGENT = 'Mylar/' +str(hash) +'(' +vers +') +http://www.github.com/evilhero/mylar/'
logger.info('Version information: %s [%s]' % (mylar.CONFIG.GIT_BRANCH, mylar.CURRENT_VERSION))
if mylar.CONFIG.CHECK_GITHUB_ON_STARTUP:
try:
mylar.LATEST_VERSION = checkGithub() #(CURRENT_VERSION)
except:
mylar.LATEST_VERSION = mylar.CURRENT_VERSION
else:
mylar.LATEST_VERSION = mylar.CURRENT_VERSION
if mylar.CONFIG.AUTO_UPDATE:
if mylar.CURRENT_VERSION != mylar.LATEST_VERSION and mylar.INSTALL_TYPE != 'win' and mylar.COMMITS_BEHIND > 0:
logger.info('Auto-updating has been enabled. Attempting to auto-update.')
mylar.SIGNAL = 'update'
示例9: run
def run(self):
logger.info('[VersionCheck] Checking for new release on Github.')
helpers.job_management(write=True, job='Check Version', current_run=helpers.utctimestamp(), status='Running')
mylar.VERSION_STATUS = 'Running'
versioncheck.checkGithub()
helpers.job_management(write=True, job='Check Version', last_run_completed=helpers.utctimestamp(), status='Waiting')
mylar.VERSION_STATUS = 'Waiting'
示例10: notify
def notify(self, ComicName=None, Year=None, Issue=None, sent_to=None, snatched_nzb=None, username=None, force=False):
"""
Sends a boxcar notification based on the provided info or SB config
title: The title of the notification to send
message: The message string to send
username: The username to send the notification to (optional, defaults to the username in the config)
force: If True then the notification will be sent even if Boxcar is disabled in the config
"""
if not mylar.BOXCAR_ENABLED and not force:
logger.fdebug("Notification for Boxcar not enabled, skipping this notification")
return False
# if no username was given then use the one from the config
if not username:
username = mylar.BOXCAR_USERNAME
if snatched_nzb:
title = "Mylar. Sucessfully Snatched!"
message = "Mylar has snatched: " + snatched_nzb + " and has sent it to " + sent_to
else:
title = "Mylar. Successfully Downloaded & Post-Processed!"
message = "Mylar has downloaded and postprocessed: " + ComicName + ' (' + Year + ') #' + Issue
logger.info("Sending notification to Boxcar")
self._sendBoxcar(message, title, username)
return True
示例11: start
def start():
global __INITIALIZED__, started
if __INITIALIZED__:
# Start our scheduled background tasks
#from mylar import updater, searcher, librarysync, postprocessor
from mylar import updater, search, weeklypull
SCHED.add_interval_job(updater.dbUpdate, hours=48)
SCHED.add_interval_job(search.searchforissue, minutes=SEARCH_INTERVAL)
#SCHED.add_interval_job(librarysync.libraryScan, minutes=LIBRARYSCAN_INTERVAL)
#weekly pull list gets messed up if it's not populated first, so let's populate it then set the scheduler.
logger.info("Checking for existance of Weekly Comic listing...")
PULLNEW = 'no' #reset the indicator here.
threading.Thread(target=weeklypull.pullit).start()
#now the scheduler (check every 24 hours)
SCHED.add_interval_job(weeklypull.pullit, hours=24)
#let's do a run at the Wanted issues here (on startup) if enabled.
if NZB_STARTUP_SEARCH:
threading.Thread(target=search.searchforissue).start()
if CHECK_GITHUB:
SCHED.add_interval_job(versioncheck.checkGithub, minutes=CHECK_GITHUB_INTERVAL)
#SCHED.add_interval_job(postprocessor.checkFolder, minutes=DOWNLOAD_SCAN_INTERVAL)
SCHED.start()
started = True
示例12: sendtohome
def sendtohome(sftp, remotepath, filelist, transport):
fhost = mylar.CONFIG.TAB_HOST.find(':')
host = mylar.CONFIG.TAB_HOST[:fhost]
port = int(mylar.CONFIG.TAB_HOST[fhost +1:])
successlist = []
filestotal = len(filelist)
for files in filelist:
tempfile = files['filename']
issid = files['issueid']
logger.fdebug('Checking filename for problematic characters: ' + tempfile)
#we need to make the required directory(ies)/subdirectories before the get will work.
if u'\xb4' in files['filename']:
# right quotation
logger.fdebug('detected abnormal character in filename')
filename = tempfile.replace('0xb4', '\'')
if u'\xbd' in files['filename']:
# 1/2 character
filename = tempfile.replace('0xbd', 'half')
if u'\uff1a' in files['filename']:
#some unknown character
filename = tempfile.replace('\0ff1a', '-')
#now we encode the structure to ascii so we can write directories/filenames without error.
filename = tempfile.encode('ascii', 'ignore')
remdir = remotepath
if mylar.CONFIG.MAINTAINSERIESFOLDER == 1:
# Get folder path of issue
comicdir = os.path.split(files['filepath'])[0]
# Isolate comic folder name
comicdir = os.path.split(comicdir)[1]
logger.info('Checking for Comic Folder: ' + comicdir)
chkdir = os.path.join(remdir, comicdir)
try:
sftp.stat(chkdir)
except IOError, e:
logger.info('Comic Folder does not Exist, creating ' + chkdir )
try:
sftp.mkdir(chkdir)
except :
# Fallback to default behavior
logger.info('Could not create Comic Folder, adding to device root')
else :
remdir = chkdir
else :
remdir = chkdir
localsend = files['filepath']
logger.info('Sending : ' + localsend)
remotesend = os.path.join(remdir, filename)
logger.info('To : ' + remotesend)
try:
sftp.stat(remotesend)
except IOError, e:
if e[0] == 2:
filechk = False
示例13: sendfiles
def sendfiles(filelist):
try:
import paramiko
except ImportError:
logger.fdebug('paramiko not found on system. Please install manually in order to use seedbox option')
logger.fdebug('get it at https://github.com/paramiko/paramiko')
logger.fdebug('to install: python setup.py install')
logger.fdebug('aborting send.')
return
fhost = mylar.CONFIG.TAB_HOST.find(':')
host = mylar.CONFIG.TAB_HOST[:fhost]
port = int(mylar.CONFIG.TAB_HOST[fhost +1:])
logger.fdebug('Destination: ' + host)
logger.fdebug('Using SSH port : ' + str(port))
transport = paramiko.Transport((host, port))
password = mylar.CONFIG.TAB_PASS
username = mylar.CONFIG.TAB_USER
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
remotepath = mylar.CONFIG.TAB_DIRECTORY
logger.fdebug('remote path set to ' + remotepath)
if len(filelist) > 0:
logger.info('Initiating send for ' + str(len(filelist)) + ' files...')
return sendtohome(sftp, remotepath, filelist, transport)
示例14: resumeArtist
def resumeArtist(self, ComicID):
logger.info(u"Resuming comic: " + ComicID)
myDB = db.DBConnection()
controlValueDict = {'ComicID': ComicID}
newValueDict = {'Status': 'Active'}
myDB.upsert("comics", newValueDict, controlValueDict)
raise cherrypy.HTTPRedirect("artistPage?ComicID=%s" % ComicID)
示例15: notify
def notify(self, ComicName=None, Year=None, Issue=None, snatched_nzb=None, sent_to=None):
apikey = self.apikey
priority = self.priority
if snatched_nzb:
event = snatched_nzb + " snatched!"
description = "Mylar has snatched: " + snatched_nzb + " and has sent it to " + sent_to
else:
event = ComicName + " (" + Year + ") - Issue #" + Issue + " complete!"
description = "Mylar has downloaded and postprocessed: " + ComicName + " (" + Year + ") #" + Issue
data = {
"apikey": apikey,
"application": "Mylar",
"event": event,
"description": description,
"priority": priority,
}
logger.info("Sending notification request to NotifyMyAndroid")
request = self._send(data)
if not request:
logger.warn("Error sending notification request to NotifyMyAndroid")