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


Python logger.debug函数代码示例

本文整理汇总了Python中mylar.logger.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: notify

    def notify(self, message, subject, module=None):
        if module is None:
            module = ''
        module += '[NOTIFIER]'
        sent_successfully = False

        try:
            logger.debug(module + u' Sending email notification. From: [%s] - To: [%s] - Server: [%s] - Port: [%s] - Username: [%s] - Password: [********] - Encryption: [%s] - Message: [%s]' % (self.emailfrom, self.emailto, self.emailsvr, self.emailport, self.emailuser, self.emailenc, message))
            msg = MIMEMultipart()
            msg['From'] = str(self.emailfrom)
            msg['To'] = str(self.emailto)
            msg['Subject'] = subject
            msg.attach(MIMEText(message, 'plain'))

            if self.emailenc is 1:
                sock = smtplib.SMTP_SSL(self.emailsvr, str(self.emailport))
            else:
                sock = smtplib.SMTP(self.emailsvr, str(self.emailport))

            if self.emailenc is 2:
                sock.starttls()

            if self.emailuser or self.emailpass:
                sock.login(str(self.emailuser), str(self.emailpass))

            sock.sendmail(str(self.emailfrom), str(self.emailto), msg.as_string())
            sock.quit()
            sent_successfully = True

        except Exception, e:
            logger.warn(module + u' Oh no!! Email notification failed: ' + str(e))
开发者ID:evilhero,项目名称:mylar,代码行数:31,代码来源:notifiers.py

示例2: addfile

    def addfile(self, filepath=None, filename=None, bytes=None):
        params = {'action': 'add-file', 'token': self.token}
        try:
            d = open(filepath, 'rb')
            tordata = d.read()
            d.close()
        except:
            logger.warn('Unable to load torrent file. Aborting at this time.')
            return 'fail'

        files = {'torrent_file': tordata}
        try:
            r = requests.post(url=self.utorrent_url, auth=self.auth, cookies=self.cookies, params=params, files=files)
        except requests.exceptions.RequestException as err:
            logger.debug('URL: ' + str(self.utorrent_url))
            logger.debug('Error sending to uTorrent Client. uTorrent responded with error: ' + str(err))
            return 'fail'


        # (to-do) verify the hash in order to ensure it's loaded here
        if str(r.status_code) == '200':
            logger.info('Successfully added torrent to uTorrent client.')
            hash = self.calculate_torrent_hash(data=tordata)
            if mylar.UTORRENT_LABEL:
                try:
                    self.setlabel(hash)
                except:
                    logger.warn('Unable to set label for torrent.')
            return hash
        else:
            return 'fail'
开发者ID:rupaschomaker,项目名称:mylar,代码行数:31,代码来源:utorrent.py

示例3: get_torrent

    def get_torrent(self, torrent):
        torrent = self.conn.get_torrent(torrent.hashString)
        torrent_files = []
        torrent_directory = os.path.normpath(torrent.downloadDir)

        for f in torrent.files().itervalues():
            if not os.path.normpath(f['name']).startswith(torrent_directory):
                file_path = os.path.join(torrent_directory,
                                         f['name'].lstrip('/'))
            else:
                file_path = f['name']

            torrent_files.append(file_path)

        torrent_info = {
            'hash': torrent.hashString,
            'name': torrent.name,
            'folder': torrent.downloadDir,
            'completed': torrent.progress == 100,
            'label': 'None', ## labels not supported in transmission - for when it's in transmission
            'files': torrent_files,
            'upload_total': torrent.uploadedEver,
            'download_total': torrent.downloadedEver,
            'ratio': torrent.ratio,
            'total_filesize': torrent.sizeWhenDone,
            'time_started': torrent.date_started
        }
        logger.debug(torrent_info)
        return torrent_info if torrent_info else False
开发者ID:rupaschomaker,项目名称:mylar,代码行数:29,代码来源:transmission.py

示例4: markissues

    def markissues(self, action=None, **args):
        myDB = db.DBConnection()
        issuesToAdd = []
        issuestoArchive = []
        if action == 'WantedNew':
            newaction = 'Wanted'
        else:
            newaction = action
        for IssueID in args:
            if IssueID is None: continue
            else:
                mi = myDB.action("SELECT * FROM issues WHERE IssueID=?",[IssueID]).fetchone()
                miyr = myDB.action("SELECT ComicYear FROM comics WHERE ComicID=?", [mi['ComicID']]).fetchone()
                if action == 'Downloaded':
                    if mi['Status'] == "Skipped" or mi['Status'] == "Wanted":
                        logger.info(u"Cannot change status to %s as comic is not Snatched or Downloaded" % (newaction))
                        continue
                elif action == 'Archived':
                    logger.info(u"Marking %s %s as %s" % (mi['ComicName'], mi['Issue_Number'], newaction))
                    #updater.forceRescan(mi['ComicID'])
                    issuestoArchive.append(IssueID)
                elif action == 'Wanted':
                    logger.info(u"Marking %s %s as %s" % (mi['ComicName'], mi['Issue_Number'], newaction))
                    issuesToAdd.append(IssueID)

                controlValueDict = {"IssueID": IssueID}
                newValueDict = {"Status": newaction}
                myDB.upsert("issues", newValueDict, controlValueDict)
        if len(issuestoArchive) > 0:
            updater.forceRescan(mi['ComicID'])
        if len(issuesToAdd) > 0:
            logger.debug("Marking issues: %s as Wanted" % issuesToAdd)
            threading.Thread(target=search.searchIssueIDList, args=[issuesToAdd]).start()
        #if IssueID:
        raise cherrypy.HTTPRedirect("artistPage?ComicID=%s" % mi['ComicID'])
开发者ID:ahnatar,项目名称:mylar,代码行数:35,代码来源:webserve.py

示例5: find_torrent

 def find_torrent(self, hash):
     logger.debug('Finding Torrent hash: ' + hash)
     torrent_info = self.get_torrent(hash)
     if torrent_info:
         return True
     else:
         return False
开发者ID:2mny,项目名称:mylar,代码行数:7,代码来源:deluge.py

示例6: get_torrent

 def get_torrent(self, hash):
     logger.debug('Getting Torrent info hash: ' + hash)
     try:
         torrent_info = self.client.get_torrent(hash)
     except Exception as e:
         logger.error('Could not get torrent info for ' + hash)
         return False
     else:
         logger.info('Successfully located information for torrent')
         return torrent_info
开发者ID:2mny,项目名称:mylar,代码行数:10,代码来源:qbittorrent.py

示例7: _get_token

 def _get_token(self):
     url = urlparse.urljoin(self.base_url, "gui/token.html")
     try:
         response = self.opener.open(url)
     except urllib2.HTTPError as err:
         logger.debug("URL: " + str(url))
         logger.debug("Error getting Token. uTorrent responded with error: " + str(err))
         return
     match = re.search(utorrentclient.TOKEN_REGEX, response.read())
     return match.group(1)
开发者ID:CptanPanic,项目名称:mylar,代码行数:10,代码来源:utorrent.py

示例8: get_torrent

 def get_torrent(self, hash):
     logger.debug('Getting Torrent info hash: ' + hash)
     try:
         torrent_info = self.client.call('core.get_torrent_status', hash, '')
     except Exception as e:
         logger.error('Could not get torrent info for ' + hash)
         return False
     else:
         logger.info('Getting Torrent Info!')
         return torrent_info
开发者ID:CptanPanic,项目名称:mylar,代码行数:10,代码来源:deluge.py

示例9: get_the_hash

    def get_the_hash(self, filepath):
        import hashlib, StringIO
        import bencode

        # Open torrent file
        torrent_file = open(filepath, "rb")
        metainfo = bencode.decode(torrent_file.read())
        info = metainfo['info']
        thehash = hashlib.sha1(bencode.encode(info)).hexdigest().upper()
        logger.debug('Hash: ' + thehash)
        return thehash
开发者ID:2mny,项目名称:mylar,代码行数:11,代码来源:deluge.py

示例10: get_artwork_from_cache

    def get_artwork_from_cache(self, ComicID=None, imageURL=None):
        """
        Pass a comicvine id to this function (either ComicID or IssueID)
        """

        self.query_type = "artwork"

        if ComicID:
            self.id = ComicID
            self.id_type = "comic"
        else:
            self.id = IssueID
            self.id_type = "issue"

        if self._exists("artwork") and self._is_current(filename=self.artwork_files[0]):
            return self.artwork_files[0]
        else:
            # we already have the image for the comic in the sql db. Simply retrieve it, and save it.
            image_url = imageURL
            logger.debug("Retrieving comic image from: " + image_url)
            try:
                artwork = urllib2.urlopen(image_url, timeout=20).read()
            except Exception, e:
                logger.error('Unable to open url "' + image_url + '". Error: ' + str(e))
                artwork = None

            if artwork:

                # Make sure the artwork dir exists:
                if not os.path.isdir(self.path_to_art_cache):
                    try:
                        os.makedirs(self.path_to_art_cache)
                    except Exception, e:
                        logger.error("Unable to create artwork cache dir. Error: " + str(e))
                        self.artwork_errors = True
                        self.artwork_url = image_url
                # Delete the old stuff
                for artwork_file in self.artwork_files:
                    try:
                        os.remove(artwork_file)
                    except:
                        logger.error("Error deleting file from the cache: " + artwork_file)

                ext = os.path.splitext(image_url)[1]

                artwork_path = os.path.join(self.path_to_art_cache, self.id + "." + helpers.today() + ext)
                try:
                    f = open(artwork_path, "wb")
                    f.write(artwork)
                    f.close()
                except Exception, e:
                    logger.error("Unable to write to the cache dir: " + str(e))
                    self.artwork_errors = True
                    self.artwork_url = image_url
开发者ID:CptanPanic,项目名称:mylar,代码行数:54,代码来源:cache.py

示例11: check_setting_int

def check_setting_int(config, cfg_name, item_name, def_val):
    try:
        my_val = int(config[cfg_name][item_name])
    except:
        my_val = def_val
        try:
            config[cfg_name][item_name] = my_val
        except:
            config[cfg_name] = {}
            config[cfg_name][item_name] = my_val
    logger.debug(item_name + " -> " + str(my_val))
    return my_val
开发者ID:Nobrumski,项目名称:mylar,代码行数:12,代码来源:__init__.py

示例12: _get_token

    def _get_token(self):
        TOKEN_REGEX = r'<div[^>]*id=[\"\']token[\"\'][^>]*>([^<]*)</div>'
        utorrent_url_token = '%stoken.html' % self.utorrent_url
        try:
            r = requests.get(utorrent_url_token, auth=self.auth)
        except requests.exceptions.RequestException as err:
            logger.debug('URL: ' + str(utorrent_url_token))
            logger.debug('Error getting Token. uTorrent responded with error: ' + str(err))
            return 'fail'

        token = re.search(TOKEN_REGEX, r.text).group(1)
        guid = r.cookies['GUID']
        cookies = dict(GUID = guid)
        return token, cookies
开发者ID:rupaschomaker,项目名称:mylar,代码行数:14,代码来源:utorrent.py

示例13: valid_login_attempt

        def valid_login_attempt(self, un, pw):
            '''
                Does the actual POST to the login.php method (using the ajax parameter, which is far more reliable
                than HTML parsing.

                Input: un: The username (usually would be self.un, but that's not a requirement
                       pw: The password (usually self.pw but not a requirement)

                Note: The underlying self.ses object will handle setting the session cookie from a valid login,
                but you'll need to call the save method if your cookies are being persisted.

                Returns: True (success) False (failure)

            '''

            postdata = {'username': un, 'password': pw, 'keeplogged': 1}
            u = 'https://32pag.es/login.php?ajax=1'

            try:
                r = self.ses.post(u, data=postdata, timeout=60, allow_redirects=True)
                logger.debug(self.module + ' Status Code: ' + str(r.status_code))
            except Exception as e:
                logger.error(self.module + " Got an exception when trying to login to %s POST", u)
                self.error = {'status':'exception', 'message':'Exception when trying to login'}
                return False

            if r.status_code != 200:
                logger.warn(self.module + " Got bad status code from login POST: %d\n%s\n%s", r.status_code, r.text, r.headers)
                logger.debug(self.module + " Request URL: %s \n Content: %s \n History: %s", r.url ,r.text, r.history)
                self.error = {'status':'Bad Status code', 'message':(r.status_code, r.text, r.headers)}
                return False

            try:
                logger.debug(self.module + ' Trying to analyze login JSON reply from 32P: %s', r.text)
                d = r.json()
            except:
                logger.debug(self.module + " Request URL: %s \n Content: %s \n History: %s", r.url ,r.text, r.history)
                logger.error(self.module + " The data returned by the login page was not JSON: %s", r.text)
                self.error = {'status':'JSON not returned', 'message':r.text}
                return False

            if d['status'] == 'success':
                return True

            logger.error(self.module + " Got unexpected status result: %s", d)
            logger.debug(self.module + " Request URL: %s \n Content: %s \n History: %s \n Json: %s", r.url ,r.text, r.history, d)
            self.error = d
            return False
开发者ID:rupaschomaker,项目名称:mylar,代码行数:48,代码来源:auth32p.py

示例14: check_setting_str

def check_setting_str(config, cfg_name, item_name, def_val, log=True):
    try:
        my_val = config[cfg_name][item_name]
    except:
        my_val = def_val
        try:
            config[cfg_name][item_name] = my_val
        except:
            config[cfg_name] = {}
            config[cfg_name][item_name] = my_val

    if log:
        logger.debug(item_name + " -> " + my_val)
    else:
        logger.debug(item_name + " -> ******")
    return my_val
开发者ID:Nobrumski,项目名称:mylar,代码行数:16,代码来源:__init__.py

示例15: calculate_torrent_hash

def calculate_torrent_hash(link, data=None):
    """
    Calculate the torrent hash from a magnet link or data. Raises a ValueError
    when it cannot create a torrent hash given the input data.
    """

    if link.startswith("magnet:"):
        torrent_hash = re.findall("urn:btih:([\w]{32,40})", link)[0]
        if len(torrent_hash) == 32:
            torrent_hash = b16encode(b32decode(torrent_hash)).lower()
    elif data:
        info = bdecode(data)["info"]
        torrent_hash = sha1(bencode(info)).hexdigest()
    else:
        raise ValueError("Cannot calculate torrent hash without magnet link " "or data")
    logger.debug("Torrent hash: " + torrent_hash)
    return torrent_hash.upper()
开发者ID:CptanPanic,项目名称:mylar,代码行数:17,代码来源:utorrent.py


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