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


Python logger.debug函数代码示例

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


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


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