• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python logger.debug函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: delete

    def delete(self, resources=[], languages=[], skip=False, force=False):
        """Delete translations."""
        resource_list = self.get_chosen_resources(resources)
        self.skip = skip
        self.force = force

        if not languages:
            delete_func = self._delete_resource
        else:
            delete_func = self._delete_translations

        for resource in resource_list:
            project_slug, resource_slug = resource.split('.', 1)
            host = self.get_resource_host(resource)
            self.url_info = {
                'host': host,
                'project': project_slug,
                'resource': resource_slug
            }
            logger.debug("URL data are: %s" % self.url_info)
            json, _ = self.do_url_request('project_details', project=self)
            project_details = parse_json(json)
            teams = project_details['teams']
            stats = self._get_stats_for_resource()
            delete_func(project_details, resource, stats, languages)
开发者ID:akx,项目名称:transifex-client,代码行数:25,代码来源:project.py


示例2: _get_git_dir

    def _get_git_dir(self, path):
        """Check if path lies within a git directory, and return that

            Args:
                path a complete filepath
            Returns:
                (<repotype>, dirname, basename)
        """
        d, t = os.path.split(path)
        h = d

        while h:
            if h in ('/', '/home', '/net'):
                # don't even try these!
                break
            # rQ : are we allowed to go up from self.root ?

            hit = self._git_dirs_cache.get(h,None)
            if hit is False:
                # /negative/ cache
                raise KeyError(h)
            elif hit is None:
                # not cached, we must check further
                if os.path.isdir(os.path.join(h, '.git')):
                    hit = 'git'
                if hit:
                    self._git_dirs_cache[h] = hit
            if hit:
                logger.debug("Hit!, %s is a %s dir", h, hit)
                return hit, d, t
            else:
                h = os.path.split(h)[0]
        
        raise KeyError(d)
开发者ID:xrg,项目名称:transifex-client,代码行数:34,代码来源:project.py


示例3: get_chosen_resources

    def get_chosen_resources(self, resources):
        """Get the resources the user selected.

        Support wildcards in the resources specified by the user.

        Args:
            resources: A list of resources as specified in command-line or
                an empty list.
        Returns:
            A list of resources.
        """
        configured_resources = self.get_resource_list()
        if not resources:
            return configured_resources

        selected_resources = []
        for resource in resources:
            found = False
            for full_name in configured_resources:
                if fnmatch.fnmatch(full_name, resource):
                    selected_resources.append(full_name)
                    found = True
            if not found:
                msg = "Specified resource '%s' does not exist."
                raise Exception(msg % resource)
        logger.debug("Operating on resources: %s" % selected_resources)
        return selected_resources
开发者ID:akx,项目名称:transifex-client,代码行数:27,代码来源:project.py


示例4: delete

    def delete(self, resources=[], languages=[], skip=False):
        """Delete translations."""
        resource_list = self.get_chosen_resources(resources)
        for resource in resources:
            delete_languages = []
            files = self.get_resource_files(resource)
            project_slug, resource_slug = resource.split('.')
            lang_map = self.get_resource_lang_mapping(resource)
            host = self.get_resource_host(resource)

            url_info = {
                'host': host,
                'project': project_slug,
                'resource': resource_slug
            }
            logger.debug("URL data are: %s" % url_info)

            MSG("Deleting translations for resource %s:" % resource)
            if not languages:
                logger.warning("No languages specified.")
                return
            for language in languages:
                try:
                    self.do_url_request(
                        'delete_translation', url_info, language=language, method="DELETE"
                    )
                    msg = "Deleted language %s from resource %s in project %s."
                    MSG(msg % (language, resource_slug, project_slug))
                except Exception, e:
                    msg = "ERROR: Unable to delete translation %s.%s.%s"
                    MSG(msg % (project_slug, resource_slug, language))
                    if not skip:
                        raise
开发者ID:tbarbugli,项目名称:transifex-client,代码行数:33,代码来源:project.py


示例5: _should_push_translation

    def _should_push_translation(self, lang, stats, local_file, force=False):
        """Return whether a local translation file should be
        pushed to Trasnifex.

        We use the following criteria for that:
        - If user requested to force the upload.
        - If language exists in Transifex.
        - If local file is younger than the remote file.

        Args:
            lang: The language code to check.
            stats: The (global) statistics object.
            local_file: The local translation file.
            force: A boolean flag.
        Returns:
            True or False.
        """
        if force:
            logger.debug("Push translation due to -f.")
            return True
        try:
            lang_stats = stats[lang]
        except KeyError, e:
            logger.debug("Language %s does not exist in Transifex." % lang)
            return True
开发者ID:sayanchowdhury,项目名称:transifex-client,代码行数:25,代码来源:project.py


示例6: get_details

def get_details(api_call, username, password, *args, **kwargs):
    """
    Get the tx project info through the API.

    This function can also be used to check the existence of a project.
    """
    url = (API_URLS[api_call] % (kwargs)).encode('UTF-8')
    conn = urllib3.connection_from_url(kwargs['hostname'])
    headers = urllib3.util.make_headers(
        basic_auth='{0}:{1}'.format(username, password),
        accept_encoding=True,
        user_agent=user_agent_identifier(),
    )
    try:
        r = conn.request('GET', url, headers=headers)
        if r.status < 200 or r.status >= 400:
            raise Exception(r.data)
        remote_project = parse_json(r.data)
        return remote_project
    except ssl.SSLError:
        logger.error("Invalid SSL certificate")
        raise
    except Exception, e:
        logger.debug(unicode(e))
        raise
开发者ID:stefanw,项目名称:transifex-client,代码行数:25,代码来源:utils.py


示例7: _init

    def _init(self, path_to_tx=None):
        # The path to the root of the project, where .tx lives!
        self.root = path_to_tx or find_dot_tx()
        logger.debug("Path to tx is %s." % self.root)
        if not self.root:
            MSG("Cannot find any .tx directory!")
            MSG("Run 'tx init' to initialize your project first!")
            raise ProjectNotInit()

        # The path to the config file (.tx/config)
        self.config_file = os.path.join(self.root, ".tx", "config")
        logger.debug("Config file is %s" % self.config_file)
        # Touch the file if it doesn't exist
        if not os.path.exists(self.config_file):
            MSG("Cannot find the config file (.tx/config)!")
            MSG("Run 'tx init' to fix this!")
            raise ProjectNotInit()

        # The dictionary which holds the config parameters after deser/tion.
        # Read the config in memory
        self.config = OrderedRawConfigParser()
        try:
            self.config.read(self.config_file)
        except Exception, err:
            MSG("WARNING: Cannot open/parse .tx/config file", err)
            MSG("Run 'tx init' to fix this!")
            raise ProjectNotInit()
开发者ID:tbarbugli,项目名称:transifex-client,代码行数:27,代码来源:project.py


示例8: _get_config_file_path

 def _get_config_file_path(self, root_path):
     """Check the .tx/config file exists."""
     config_file = os.path.join(root_path, ".tx", "config")
     logger.debug("Config file is %s" % config_file)
     if not os.path.exists(config_file):
         msg = "Cannot find the config file (.tx/config)!"
         raise ProjectNotInit(msg)
     return config_file
开发者ID:akx,项目名称:transifex-client,代码行数:8,代码来源:project.py


示例9: _get_tx_dir_path

 def _get_tx_dir_path(self, path_to_tx):
     """Check the .tx directory exists."""
     root_path = path_to_tx or find_dot_tx()
     logger.debug("Path to tx is %s." % root_path)
     if not root_path:
         msg = "Cannot find any .tx directory!"
         raise ProjectNotInit(msg)
     return root_path
开发者ID:akx,项目名称:transifex-client,代码行数:8,代码来源:project.py


示例10: do_url_request

    def do_url_request(self, api_call, multipart=False, data=None,
                       files=[], method="GET", **kwargs):
        """
        Issues a url request.
        """
        # Read the credentials from the config file (.transifexrc)
        host = self.url_info['host']
        try:
            username = self.txrc.get(host, 'username')
            passwd = self.txrc.get(host, 'password')
            token = self.txrc.get(host, 'token')
            hostname = self.txrc.get(host, 'hostname')
        except ConfigParser.NoSectionError:
            raise Exception("No user credentials found for host %s. Edit"
                " ~/.transifexrc and add the appropriate info in there." %
                host)

        # Create the Url
        kwargs['hostname'] = hostname
        kwargs.update(self.url_info)
        url = (API_URLS[api_call] % kwargs).encode('UTF-8')
        logger.debug(url)

        if multipart:
            for info, filename in files:
                name = os.path.basename(filename)
                data = {
                    "resource": info.split(';')[0],
                    "language": info.split(';')[1],
                    "uploaded_file": (name, open(filename, 'rb').read())
                }
            headers = urllib3.util.make_headers(
                basic_auth='{0}:{1}'.format(username, passwd),
                accept_encoding=True,
                user_agent=user_agent_identifier(),
                keep_alive=True
            )
            r = self.conn.request(
                method, url, fields=data, headers=headers
            )
        else:
            headers = urllib3.util.make_headers(
                basic_auth='{0}:{1}'.format(username, passwd),
                accept_encoding=True,
                user_agent=user_agent_identifier(),
                keep_alive=True
            )
            r = self.conn.request(
                method, url, fields=data, headers=headers
            )

        r.close()
        if r.status < 200 or r.status >= 400:
            if r.status == 404:
                raise HttpNotFound(r.data)
            else:
                raise Exception(r.data)
        return r.data
开发者ID:mpessas,项目名称:transifex-client,代码行数:58,代码来源:project.py


示例11: do_url_request

    def do_url_request(self, api_call, multipart=False, data=None,
                       files=[], encoding=None, method="GET", **kwargs):
        """
        Issues a url request.
        """
        # Read the credentials from the config file (.transifexrc)
        host = self.url_info['host']
        try:
            username = self.txrc.get(host, 'username')
            passwd = self.txrc.get(host, 'password')
            token = self.txrc.get(host, 'token')
            hostname = self.txrc.get(host, 'hostname')
        except ConfigParser.NoSectionError:
            raise Exception("No user credentials found for host %s. Edit"
                " ~/.transifexrc and add the appropriate info in there." %
                host)

        # Create the Url
        kwargs['hostname'] = hostname
        kwargs.update(self.url_info)
        url = (API_URLS[api_call] % kwargs).encode('UTF-8')
        logger.debug(url)

        opener = None
        headers = None
        req = None

        if multipart:
            opener = urllib2.build_opener(MultipartPostHandler)
            for info,filename in files:
                data = { "resource" : info.split(';')[0],
                         "language" : info.split(';')[1],
                         "uploaded_file" :  open(filename,'rb') }

            urllib2.install_opener(opener)
            req = RequestWithMethod(url=url, data=data, method=method)
        else:
            req = RequestWithMethod(url=url, data=data, method=method)
            if encoding:
                req.add_header("Content-Type",encoding)

        base64string = base64.encodestring('%s:%s' % (username, passwd))[:-1]
        authheader = "Basic %s" % base64string
        req.add_header("Authorization", authheader)
        req.add_header("Accept-Encoding", "gzip,deflate")
        req.add_header("User-Agent", user_agent_identifier())

        try:
            response = urllib2.urlopen(req, timeout=300)
            return http_response(response)
        except urllib2.HTTPError, e:
            if e.code in [401, 403, 404]:
                raise e
            elif 200 <= e.code < 300:
                return None
            else:
                # For other requests, we should print the message as well
                raise Exception("Remote server replied: %s" % e.read())
开发者ID:gisce,项目名称:transifex-client,代码行数:58,代码来源:project.py


示例12: _get_stats_for_resource

 def _get_stats_for_resource(self):
     """Get the statistics information for a resource."""
     try:
         r = self.do_url_request('resource_stats')
         logger.debug("Statistics response is %s" % r)
         stats = parse_json(r)
     except urllib2.HTTPError, e:
         logger.debug("Resource not found: %s" % e)
         stats = {}
开发者ID:sayanchowdhury,项目名称:transifex-client,代码行数:9,代码来源:project.py


示例13: _get_stats_for_resource

 def _get_stats_for_resource(self, url_info):
     """Get the statistics information for a resource."""
     try:
         r = self.do_url_request('resource_stats', url_info)
         logger.debug("Statistics response is %s" % r)
         stats = parse_json(r)
     except Exception,e:
         logger.debug("Empty statistics: %s" % e)
         stats = {}
开发者ID:tbarbugli,项目名称:transifex-client,代码行数:9,代码来源:project.py


示例14: _should_download

    def _should_download(self, lang, stats, local_file=None, force=False,
                         mode=None):
        """Return whether a translation should be downloaded.

        If local_file is None, skip the timestamps check (the file does
        not exist locally).
        """
        try:
            lang_stats = stats[lang]
        except KeyError, e:
            logger.debug("No lang %s in statistics" % lang)
            return False
开发者ID:sayanchowdhury,项目名称:transifex-client,代码行数:12,代码来源:project.py


示例15: _get_stats_for_resource

 def _get_stats_for_resource(self):
     """Get the statistics information for a resource."""
     try:
         r = self.do_url_request('resource_stats')
         logger.debug("Statistics response is %s" % r)
         stats = parse_json(r)
     except ssl.SSLError:
         logger.error("Invalid SSL certificate")
         raise
     except Exception, e:
         logger.debug(unicode(e))
         raise
开发者ID:GbalsaC,项目名称:bitnamiP,代码行数:12,代码来源:project.py


示例16: _get_transifex_file

    def _get_transifex_file(self, directory=None):
        """Fetch the path of the .transifexrc file.

        It is in the home directory ofthe user by default.
        """
        if directory is None:
            directory = os.path.expanduser('~')
        txrc_file = os.path.join(directory, ".transifexrc")
        logger.debug(".transifexrc file is at %s" % directory)
        if not os.path.exists(txrc_file):
            msg = "No authentication data found."
            raise ProjectNotInit(msg)
        return txrc_file
开发者ID:zaabalonso,项目名称:transifex-client,代码行数:13,代码来源:project.py


示例17: get_details

def get_details(api_call, username, password, *args, **kwargs):
    """
    Get the tx project info through the API.

    This function can also be used to check the existence of a project.
    """
    url = API_URLS[api_call] % kwargs
    try:
        data, charset = make_request('GET', kwargs['hostname'], url, username, password)
        return parse_json(data)
    except Exception as e:
        logger.debug(six.u(str(e)))
        raise
开发者ID:shimizukawa,项目名称:transifex-client,代码行数:13,代码来源:utils.py


示例18: _set_project_option

def _set_project_option(resource, name, value, path_to_tx, func_name):
    """Save the option to the project config file."""
    if value is None:
        return
    if not resource:
        logger.debug("Setting the %s for all resources." % name)
        resources = []
    else:
        logger.debug("Setting the %s for resource %s." % (name, resource))
        resources = [resource, ]
    prj = project.Project(path_to_tx)
    getattr(prj, func_name)(resources, value)
    prj.save()
开发者ID:transifex,项目名称:Transifex_Client_wui_interface,代码行数:13,代码来源:commands.py


示例19: _get_transifex_file

    def _get_transifex_file(self, directory=None):
        """Fetch the path of the .transifexrc file.

        It is in the home directory ofthe user by default.
        """
        if directory is None:
            directory = os.path.expanduser('~')
        txrc_file = os.path.join(directory, ".transifexrc")
        logger.debug(".transifexrc file is at %s" % directory)
        if not os.path.exists(txrc_file):
            msg = "No authentication data found."
            logger.info(msg)
            mask = os.umask(077)
            open(txrc_file, 'w').close()
            os.umask(mask)
        return txrc_file
开发者ID:sayanchowdhury,项目名称:transifex-client,代码行数:16,代码来源:project.py


示例20: _new_translations_to_add

    def _new_translations_to_add(self, files, slang, lang_map,
                                 stats, force=False):
        """Return a list of translations which are
        new to the local installation.
        """
        new_translations = []
        langs = list(stats.keys())
        logger.debug("Available languages are: %s" % langs)

        for lang in langs:
            lang_exists = lang in list(files.keys())
            lang_is_source = lang == slang
            mapped_lang_exists = (
                lang in lang_map and lang_map[lang] in list(files.keys())
            )
            if lang_exists or lang_is_source or mapped_lang_exists:
                continue
            if self._should_add_translation(lang, stats, force):
                new_translations.append(lang)
        return set(new_translations)
开发者ID:TASERAxon,项目名称:transifex-client,代码行数:20,代码来源:project.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python logger.error函数代码示例发布时间:2022-05-27
下一篇:
Python config.OrderedRawConfigParser类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap