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


Python utils.log函数代码示例

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


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

示例1: on_task_finished

    def on_task_finished(self, task):
        task.sound_file.progress = 1.0

        if task.error:
            debug("error in task, skipping rename:", task.output_filename)
            if vfs_exists(task.output_filename):
                vfs_unlink(task.output_filename)
            self.errors.append(task.error)
            self.error_count += 1
            return

        duration = task.get_duration()
        if duration:
            self.duration_processed += duration

        # rename temporary file
        newname = self.window.prefs.generate_filename(task.sound_file)
        log(beautify_uri(task.output_filename), "->", beautify_uri(newname))

        # safe mode. generate a filename until we find a free one
        p, e = os.path.splitext(newname)
        p = p.replace("%", "%%")
        p = p + " (%d)" + e
        i = 1
        while vfs_exists(newname):
            newname = p % i
            i += 1

        task.error = vfs_rename(task.output_filename, newname)
        if task.error:
            self.errors.append(task.error)
            self.error_count += 1
开发者ID:nueces,项目名称:soundconverter,代码行数:32,代码来源:gstreamer.py

示例2: getImagesMjpegInterlace

    def getImagesMjpegInterlace(self, camera, url, control, prefix):
        """ Update camera position with interlaced mjpeg frames """

        try:
            stream = requests.get(url, stream=True, timeout=TIMEOUT).raw

        except requests.RequestException as e:
            utils.log(3, e)
            control[0].setImage(_error, useCache=False)
            return

        x = 0
        while not monitor.abortRequested() and self.isRunning:

            filename = os.path.join(_datapath, "%s_%s.%d.jpg") % (prefix, camera.number, x)
            filename_exists = utils.get_mjpeg_frame(stream, filename)

            if filename_exists:
                if x % 2 == 0:  # Interlacing for flicker reduction/elimination
                    control[0].setImage(filename, useCache=False)
                else:
                    control[1].setImage(filename, useCache=False)
                xbmcvfs.delete(os.path.join(_datapath, "%s_%s.%d.jpg") % (prefix, camera.number, x - 2))
                x += 1

            else:
                utils.log(3, "Camera %s - Error on MJPEG" % camera.number)
                control[0].setImage(_error, useCache=False)
                return
开发者ID:geneliu,项目名称:plugin.video.surveillanceroom,代码行数:29,代码来源:allcameraplayer.py

示例3: answer_from_div

def answer_from_div(div):
    a = Answer()
    a.author = div.xpath('.//a[@class="author-link"]')[0].text
    log('author,', a)
    content = div.xpath('.//div[@class="zm-editable-content clearfix"]/text()')
    a.content = '\n'.join(content)
    return a
开发者ID:wangjueakiyama,项目名称:wangjue,代码行数:7,代码来源:douban_zhihu.py

示例4: delete_temp_files

def delete_temp_files():
    log('Deleting temporary files...')

    os.remove(settings.BROKEN_CSV_FILE_NAME)
    os.remove(settings.FIXED_CSV_FILE_NAME)

    log('Done')
开发者ID:mybay,项目名称:mybay,代码行数:7,代码来源:generate_db.py

示例5: ebsmount_add

def ebsmount_add(devname, mountdir):
    """ebs device attached"""

    matching_devices = []
    for device in udevdb.query():
        if device.name.startswith(basename(devname)):
            matching_devices.append(device)

    for device in matching_devices:
        devpath = join('/dev', device.name)
        mountpath = join(mountdir, device.env.get('ID_FS_UUID', devpath[-1])[:6])
        mountoptions = ",".join(config.mountoptions.split())

        filesystem = device.env.get('ID_FS_TYPE', None)
        if not filesystem:
            log(devname, "could not identify filesystem: %s" % devpath)
            continue

        if not filesystem in config.filesystems.split():
            log(devname, "filesystem (%s) not supported: %s" % (filesystem,devpath))
            continue

        if is_mounted(devpath):
            log(devname, "already mounted: %s" % devpath)
            continue

        mount(devpath, mountpath, mountoptions)
        if exists(config.postmountscript):
          log(devname, "Executing: %s -m %s -d %s" % (config.postmountscript, mountpath, devname))
          res = system("exec '%s' -m %s -d %s" % (config.postmountscript, mountpath, devname))
        else:
          log(devname, "Script does not exist at %s" % config.postmountscript)
开发者ID:nickjumo,项目名称:ebsmount,代码行数:32,代码来源:ebsmount.py

示例6: export_from_db

    def export_from_db(self, full_path):
        temp_path = os.path.join(xbmc.translatePath("special://profile"), 'temp_export_%s.csv' % (int(time.time())))
        with open(temp_path, 'w') as f:
            writer = csv.writer(f)
            f.write('***VERSION: %s***\n' % self.__get_db_version())
            if self.__table_exists('favorites'):
                f.write(CSV_MARKERS.FAVORITES + '\n')
                for fav in self.get_favorites():
                    writer.writerow(fav)
            if self.__table_exists('subscriptions'):
                f.write(CSV_MARKERS.SUBSCRIPTIONS + '\n')
                for sub in self.get_subscriptions():
                    writer.writerow(sub)
            if self.__table_exists('new_bkmark'):
                f.write(CSV_MARKERS.BOOKMARKS + '\n')
                for bookmark in self.get_bookmarks():
                    writer.writerow(bookmark)
            if self.__table_exists('external_subs'):
                f.write(CSV_MARKERS.EXT_SUBS + '\n')
                for sub in self.get_external_subs():
                    writer.writerow(sub)

        utils.log('Copying export file from: |%s| to |%s|' % (temp_path, full_path), xbmc.LOGDEBUG)
        if not xbmcvfs.copy(temp_path, full_path):
            raise Exception('Export: Copy from |%s| to |%s| failed' % (temp_path, full_path))

        if not xbmcvfs.delete(temp_path):
            raise Exception('Export: Delete of %s failed.' % (temp_path))
开发者ID:beljim,项目名称:tknorris-beta-repo,代码行数:28,代码来源:db_utils.py

示例7: ensure_mongo_indexes

def ensure_mongo_indexes():
    """
    Runs commands on the mongo indexes to ensure that they are set
    :return: None
    """
    utils.log("Setting index for countries")
    cmd = config.MONGO_PATH + "mongo  --quiet " + config.MONGO_HOST + "/logs --eval \"db.clickstream.ensureIndex({country:1})\""
开发者ID:CurtinIC,项目名称:optimus_ingestor,代码行数:7,代码来源:service.py

示例8: process

	def process(self, message):
		
		end = message.get('end')
		start = message.get('start')
		startDoy = message.get('startDoy')
		startYear = message.get('startYear')
		layer = message.get('layer')
		region = message.get('region')
		productName = message.get('productName').replace('.','_')

		outputFilename = "_".join([productName, layer['name'], startYear + startDoy , region]) + '.tif'
		outputFilepath = os.path.join(self.module_path, outputFilename)

		utils.removeFileIfExist(outputFilepath)

		utils.log(self.name, 'Generating', outputFilename, 'merging', str(len(layer['files'])), 'files')
		gdal_utils.mosaic(layer['files'], outputFilepath, layer['nodata'])

		tmpFiles = message.get('tmpFiles')
		tmpFiles += layer['files']
		message.set('tmpFiles', tmpFiles)

		del layer['files']
		layer['file'] = outputFilepath
		message.set('layer', layer)

		utils.log(self.name, 'Forward message (', outputFilename, ')')
		self.publish(message)
开发者ID:lapig-ufg,项目名称:sitt,代码行数:28,代码来源:mosaic.py

示例9: _run

 def _run(self):
     utils.log("[%s] pulling from source '%s'" % (self.name, self._source.name))
     
     self._source.startProducing()
     self.processQueue(self._source._output)
     self._source.join()
     self._output.put(StopIteration)
开发者ID:Stamped,项目名称:Stamped,代码行数:7,代码来源:AEntityProxy.py

示例10: crossValidate

def crossValidate(opts):
	"""
	Starts the tree cross validation.
	The subset tree has a depth defined by the the division-depth opttion.
	Each dataset will be split into a number of subsets defined by the division-factor option.
	
	@type	opts: Options
	@param	opts: Options object
	"""
	totaltime = time.time()
	opts.training_file = scale(opts, opts.training_file)
	log("Scaling input data")
	while opts.division_depth >= 0:
		starttime = time.time()
		log("Range: C={0}; gamma={1}".format(opts.c_range,opts.g_range))
		res = crossValidationRound(opts)
		cstart,cstop,cstep = opts.c_range
		gstart,gstop,gstep = opts.g_range
		cmin,cmax,gmin,gmax = calcNewRange(res, opts)
		opts.division_depth = opts.division_depth -1
		opts.c_range = cmin,cmax,cstep
		opts.g_range = gmin,gmax,gstep
		endtime = time.time()
		log("Time for this round: {0}".format(time.strftime("%H:%M:%S", time.gmtime(endtime-starttime))))
		log("Remaining division steps: {0}".format(opts.division_depth+1))
		
	log("Total time: {}".format(time.strftime("%H:%M:%S", time.gmtime(time.time()-totaltime))))
			
开发者ID:hastern,项目名称:svmTool.py,代码行数:27,代码来源:treeCrossValidation.py

示例11: upload_log

def upload_log():
    """
        Upload our full XBMC log as a GitHub gist
    """
    try:
        log_content = get_xbmc_log()
    except Exception as e:
        utils.log("Failed to read log: %s" % e)
        return None

    utils.log("Uploading xbmc.log")
    try:
        response = urllib2.urlopen(make_request(config.GIST_API_URL), json.dumps({
            "files": {
                "xbmc.log": {
                    "content": log_content
                }
            }
        }))
    except urllib2.HTTPError as e:
        print e
        utils.log("Failed to save log: HTTPError %s" % e.code)
        return False
    except urllib2.URLError as e:
        print e
        utils.log("Failed to save log: URLError %s" % e.reason)
        return False
    try:
        return json.load(response)["html_url"]
    except:
        utils.log("Failed to parse API response: %s" % response.read())
开发者ID:sdt,项目名称:xbmc-addon-abc-iview,代码行数:31,代码来源:issue_reporter.py

示例12: get_latest_version

def get_latest_version():
    """
        Sort the list, and get the latest version
    """
    versions = get_versions()
    utils.log('Version check found versions: %s' % versions)
    return sorted(versions, reverse=True)[0]
开发者ID:sdt,项目名称:xbmc-addon-abc-iview,代码行数:7,代码来源:issue_reporter.py

示例13: setup

    def setup(self):
        if(APP_KEY == '' or APP_SECRET == ''):
            xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30058),utils.getString(30059))
            return
        
        user_token_key,user_token_secret = self.getToken()
        
        sess = session.DropboxSession(APP_KEY,APP_SECRET,"app_folder")

        if(user_token_key == '' and user_token_secret == ''):
            token = sess.obtain_request_token()
            url = sess.build_authorize_url(token)

            #print url in log
            utils.log("Authorize URL: " + url)
            xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30056),utils.getString(30057))  
            
            #if user authorized this will work
            user_token = sess.obtain_access_token(token)
            self.setToken(user_token.key,user_token.secret)
            
        else:
            sess.set_token(user_token_key,user_token_secret)
        
        self.client = client.DropboxClient(sess)

        try:
            utils.log(str(self.client.account_info()))
        except:
            #this didn't work, delete the token file
            self.deleteToken()
开发者ID:nspierbundel,项目名称:OpenELEC.tv,代码行数:31,代码来源:vfs.py

示例14: _get_totals

 def _get_totals(self):
     utils.log('calculating totals')
     df = self.df[self.independent_vars].sum().to_frame('total')
     df = df.set_value('tds_0','total',None)
     df = df.set_value('tds_1','total',None)
     df = df.reset_index().rename(columns={'index':'independent_variable'})
     return df
开发者ID:jmaddock,项目名称:wiki_languages,代码行数:7,代码来源:population_summary_stats.py

示例15: connect_to_sql

    def connect_to_sql(self, sql_connect, db_name="", force_reconnect=False, create_db=True):
        """
        Connect to SQL database or create the database and connect
        :param sql_connect: the variable to set
        :param db_name: the name of the database
        :param force_reconnect: force the database connection
        :param create_db: create the database
        :return the created SQL connection
        """
        print self
        if sql_connect is None or force_reconnect:
            try:
                sql_connect = MySQLdb.connect(host=config.SQL_HOST, user=config.SQL_USERNAME, passwd=config.SQL_PASSWORD, db=db_name)
                return sql_connect
            except Exception, e:
                # Create the database
                if e[0] and create_db and db_name != "":
                    if sql_connect is None:
                        sql_connect = MySQLdb.connect(host=config.SQL_HOST, user=config.SQL_USERNAME, passwd=config.SQL_PASSWORD)
                    utils.log("Creating database " + db_name)

                    cur = sql_connect.cursor()
                    cur.execute("CREATE DATABASE " + db_name)
                    sql_connect.commit()
                    sql_connect.select_db(db_name)
                    return sql_connect
                else:
                    utils.log("Could not connect to MySQL: %s" % e)
                    return None
开发者ID:UQ-UQx,项目名称:optimus_ingestor,代码行数:29,代码来源:service.py


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