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

Python util.timestamp函数代码示例

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

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



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

示例1: list_trash

def list_trash(cookie, tokens, path="/", page=1, num=100):
    """获取回收站的信息.

    path - 目录的绝对路径, 默认是根目录
    page - 页码, 默认是第一页
    num - 每页有多少个文件, 默认是100个.
    回收站里面的文件会被保存10天, 10天后会自动被清空.
    回收站里面的文件不占用用户的存储空间.
    """
    url = "".join(
        [
            const.PAN_API_URL,
            "recycle/list?channel=chunlei&clienttype=0&web=1",
            "&num=",
            str(num),
            "&t=",
            util.timestamp(),
            "&dir=",
            encoder.encode_uri_component(path),
            "&t=",
            util.latency(),
            "&order=time&desc=1",
            "&_=",
            util.timestamp(),
            "&bdstoken=",
            tokens["bdstoken"],
        ]
    )
    req = net.urlopen(url, headers={"Cookie": cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:BuddhismZhang,项目名称:bcloud,代码行数:34,代码来源:pcs.py


示例2: new_from_url

	def new_from_url ( url ):
		try:
			d = feedparser.parse( url )
			if not d.has_key( 'status' ):
				raise Exception( 'Error fetching content. Bad URL?' )
			if d.status != 200 and d.status != 301 and d.status != 302:
				raise Exception( d.debug_message)
			if not d.feed.has_key( 'title' ):
				raise Exception( "Content does not appear to be an RSS feed." )
			
			if d.has_key( 'etag' ):
				etag = d.etag
			else:
				etag = ''
			
			if d.has_key( 'modified' ):
				modified = d['modified']
			else:
				modified = datetime.now().timetuple()
			
			feed = Feed()
			feed.url = d.href
			feed.title = d.feed.title
			feed.link = d.feed.link
			try:
				feed.description = d.feed.description
			except AttributeError, e:
				pass
			feed.etag = etag
			feed.modified = util.timestamp( modified )
			feed.added = util.timestamp()
			
			feed.insert()
			
			return feed
开发者ID:jmhobbs,项目名称:simple-mail-feeder,代码行数:35,代码来源:models.py


示例3: list_share_path

def list_share_path(cookie, tokens, uk, path, share_id, page):
    '''列举出用户共享的某一个目录中的文件信息

    uk       - user key
    path     - 共享目录
    share_id - 共享文件的ID值
    '''
    url = ''.join([
        const.PAN_URL,
        'share/list?channel=chunlei&clienttype=0&web=1&num=100',
        '&t=', util.timestamp(),
        '&page=', str(page),
        '&dir=', encoder.encode_uri_component(path),
        '&t=', util.latency(),
        '&shareid=', share_id,
        '&order=time&desc=1',
        '&uk=', uk,
        '&_=', util.timestamp(),
        '&bdstoken=', tokens['bdstoken'],
        ])
    req = net.urlopen(url, headers={
        'Cookie': cookie.header_output(),
        'Referer': const.SHARE_REFERER,
        })
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:lubing521,项目名称:bcloud,代码行数:29,代码来源:pcs.py


示例4: list_trash

def list_trash(cookie, tokens, path='/', page=1, num=100):
    '''获取回收站的信息.

    path - 目录的绝对路径, 默认是根目录
    page - 页码, 默认是第一页
    num - 每页有多少个文件, 默认是100个.
    回收站里面的文件会被保存10天, 10天后会自动被清空.
    回收站里面的文件不占用用户的存储空间.
    '''
    url = ''.join([
        const.PAN_API_URL,
        'recycle/list?channel=chunlei&clienttype=0&web=1',
        '&num=', str(num),
        '&t=', util.timestamp(),
        '&dir=', encoder.encode_uri_component(path),
        '&t=', util.latency(),
        '&order=time&desc=1',
        '&_=', util.timestamp(),
        '&bdstoken=', tokens['bdstoken'],
        ])
    req = net.urlopen(url, headers={'Cookie': cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:blueyi,项目名称:bcloud,代码行数:26,代码来源:pcs.py


示例5: list_share

def list_share(cookie, tokens, path='/', page=1, num=100):
    '''获取用户已经共享的文件的信息

    path - 哪个目录的信息, 默认为根目录.
    page - 页数, 默认为第一页.
    num - 一次性获取的共享文件的数量, 默认为100个.
    '''
    url = ''.join([
        const.PAN_URL,
        'share/record?channel=chunlei&clienttype=0&web=1',
        '&num=', str(num),
        '&t=', util.timestamp(),
        '&page=', str(page),
        '&dir=', encoder.encode_uri_component(path),
        '&t=', util.latency(), 
        '&order=tme&desc=1',
        '&_=', util.timestamp(),
        '&bdstoken=', tokens['bdstoken'],
        ])
    req = net.urlopen(url, headers={
        'Cookie': cookie.header_output(),
        'Referer': const.SHARE_REFERER,
        })
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:blueyi,项目名称:bcloud,代码行数:28,代码来源:pcs.py


示例6: run

def run ( config_path ):
	config = ConfigParser.RawConfigParser()
	config.read( config_path )
	conn = sqlite3.connect( config.get( 'Database', 'path' ) )
	cursor = conn.cursor()
	while True:
		try:
			res = cursor.execute( 'SELECT [id], [url], [modified], [etag], [interval] FROM [feeds] WHERE [checked] + [interval] < ?', ( util.timestamp(), ) )
			for row in res:
				try:
					d = feedparser.parse( row[1], etag=row[3], modified=row[2] )
					if not d.has_key( 'status' ):
						raise Exception( 'Error fetching content. Bad URL?' )
					if d.status != 200 and d.status != 301 and d.status != 302 and d.status != 304:
						raise Exception( d.debug_message)
					if not d.feed.has_key( 'title' ):
						raise Exception( "Content does not appear to be an RSS feed." )
				except Exception, e:
					conn.execute( "INSERT INTO [log] ( [logged], [level], [message] ) VALUES ( ?, ?, ? )", ( util.timestamp(), 'ERROR', 'Error fetching feed #' + str( row[0] ) + ": " + str( e ) ) )
					conn.execute( "UPDATE [feeds] SET [checked] = ? WHERE [id] = ?", ( util.timestamp() - int( row[4] / 2 ), row[0] ) )
					continue
				
				try:
					if d.status == 304:
						conn.execute( "UPDATE [feeds] SET [checked] = ? WHERE [id] = ?", ( util.timestamp(), row[0] ) )
					else:
						count = 0
						for entry in d.entries:
							result = conn.execute( "SELECT COUNT(*) FROM messages WHERE [feed_id] = ? AND [uuid] = ?", ( row[0], entry.id ) )
							if 0 != result[0][0]:
								break
							
							conn.execute( "INSERT INTO messages ( [feed_id], [fetched], [posted], [title], [link], [uuid], [content] ) VALUES ( ?, ?, ?, ?, ?, ?, ? )", ( row[0], util.timestamp(), util.timestamp( entry.date_parsed ), entry.title, entry.link, entry.id, entry.content) )

						if d.has_key( 'etag' ):
							etag = d.etag
						else:
							etag = ''
						
						if d.has_key( 'modified' ):
							modified = modified
						else:
							modified = datetime.now().timetuple()

						conn.execute( "UPDATE [feeds] SET [checked] = ?, [modified] = ?, [etag] = ? WHERE [id] = ?", ( util.timestamp(), modified, etag, row[0] ) )
						conn.execute( "INSERT INTO [log] ( [logged], [level], [message] ) VALUES ( ?, ?, ? )", ( util.timestamp(), 'DEBUG', 'Updated feed #' + str( row[0] ) + " with " + count + " new entries." ) )
				except Exception, e:
					conn.execute( "INSERT INTO [log] ( [logged], [level], [message] ) VALUES ( ?, ?, ? )", ( util.timestamp(), 'ERROR', 'Error parsing feed #' + str( row[0] ) + ": " + str( e ) ) )

			time.sleep( 30 ) # Arbitrary...
开发者ID:jmhobbs,项目名称:simple-mail-feeder,代码行数:50,代码来源:feeder.py


示例7: thermal_detection_start

 def thermal_detection_start(self):
     self.cameraThread.start_recording()
     self.data = {
         "__type__": "thermalVideoRecording",
         "recordingDateTime": util.datetimestamp(),
         "recordingTime": util.timestamp()
         }
开发者ID:TheCacophonyProject,项目名称:Raspberry_Pi_Recorder,代码行数:7,代码来源:thermal_camera.py


示例8: __init__

 def __init__(self, name = None):
     """ create the channel """
     
     self.name = name
     self.time_c = timestamp()
     self.topic = ''
     self.users = []
开发者ID:pirogoeth,项目名称:echinus,代码行数:7,代码来源:Channel.py


示例9: get_bduss

def get_bduss(cookie, token, username, password):
    '''获取最重要的登录cookie, 拿到这个cookie后, 就得到了最终的访问授权.

    token - 使用get_token()得到的token值.
    cookie - BAIDUID 这个cookie.
    username - 用户名
    password - 明文密码

    @return 最后会返回一个list, 里面包含了登录*.baidu.com需要的授权cookies.
    '''
    url = const.PASSPORT_URL + '?login'
    data = ''.join([
        'staticpage=http%3A%2F%2Fwww.baidu.com%2Fcache%2Fuser%2Fhtml%2Fv3Jump.html',
        '&charset=utf-8',
        '&token=', token,
        '&tpl=mn&apiver=v3',
        '&tt=', util.timestamp(),
        '&codestring=&safeflg=0&u=https%3A%2F%2Fpassport.baidu.com%2F',
        '&isPhone=false&quick_user=0',
        #'&loginmerge=true&logintype=basicLogin',
        '&usernamelogin=1&spligin=rate',
        '&username=', username,
        '&password=', password,
        '&verifycode=&mem_pass=on',
        '&ppui_logintime=', get_ppui_logintime(),
        '&callback=parent.bd__pcbs__cb',
        ])
    req = net.urlopen(url, headers={
        'Cookie': cookie.header_output(),
        'Content-type': const.CONTENT_FORM,
        }, data=data.encode())
    return req.headers.get_all('Set-Cookie')
开发者ID:blueyi,项目名称:bcloud,代码行数:32,代码来源:auth.py


示例10: list_share

def list_share(cookie, tokens, uk, page=1):
    """获取用户已经共享的所有文件的信息

    uk   - user key
    page - 页数, 默认为第一页.
    num  - 一次性获取的共享文件的数量, 默认为100个.
    """
    num = 100
    start = 100 * (page - 1)
    url = "".join(
        [
            const.PAN_URL,
            "pcloud/feed/getsharelist?",
            "&t=",
            util.timestamp(),
            "&categor=0&auth_type=1&request_location=share_home",
            "&start=",
            str(start),
            "&limit=",
            str(num),
            "&query_uk=",
            str(uk),
            "&channel=chunlei&clienttype=0&web=1",
            "&bdstoken=",
            tokens["bdstoken"],
        ]
    )
    req = net.urlopen(url, headers={"Cookie": cookie.header_output(), "Referer": const.SHARE_REFERER})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:BuddhismZhang,项目名称:bcloud,代码行数:33,代码来源:pcs.py


示例11: extend

 def extend(self, iterable):
     """Append multiple records to this array."""
     now = timestamp()
     cfmap = {self.key.column_family: [Column(value, "", now)
                                       for value in iterable]}
     self._get_cas().batch_insert(self.key.keyspace, self.key.key, cfmap,
                                  self.consistency)
开发者ID:enki,项目名称:lazyboy,代码行数:7,代码来源:array.py


示例12: cloud_query_task

def cloud_query_task(cookie, tokens, task_ids):
    """查询离线下载任务的信息, 比如进度, 是否完成下载等.

    最好先用cloud_list_task() 来获取当前所有的任务, 然后调用这个函数来获取
    某项任务的详细信息.

    task_ids - 一个list, 里面至少要有一个task_id, task_id 是一个字符串
    """
    url = "".join(
        [
            const.PAN_URL,
            "rest/2.0/services/cloud_dl?method=query_task&app_id=250528",
            "&bdstoken=",
            tokens["bdstoken"],
            "&task_ids=",
            ",".join(task_ids),
            "&t=",
            util.timestamp(),
            "&channel=chunlei&clienttype=0&web=1",
        ]
    )
    req = net.urlopen(url, headers={"Cookie": cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:BuddhismZhang,项目名称:bcloud,代码行数:27,代码来源:pcs.py


示例13: insert_post

def insert_post(forum_id, thread_id, message, user_id, first_post=False, timestamp=None):
    if timestamp is None:
        timestamp = str(util.timestamp())
    query_db('INSERT INTO posts (author, thread, message, time, first_post) VALUES\
            (' + str(user_id) + ',' + str(thread_id) + ',"' + message + '",' + timestamp +',' + str(b2i(first_post)) + ')')
    query_db('UPDATE forums SET post_count = post_count + 1 WHERE id = ' + str(forum_id))
    query_db('UPDATE threads SET post_count = post_count + 1 WHERE id = ' + str(thread_id))
开发者ID:Yas3r,项目名称:svwa-1,代码行数:7,代码来源:db.py


示例14: cloud_query_sinfo

def cloud_query_sinfo(cookie, tokens, source_path):
    """获取网盘中种子的信息, 比如里面的文件名, 文件大小等.

    source_path - BT种子的绝对路径.
    """
    url = "".join(
        [
            const.PAN_URL,
            "rest/2.0/services/cloud_dl?channel=chunlei&clienttype=0&web=1",
            "&method=query_sinfo&app_id=250528",
            "&bdstoken=",
            tokens["bdstoken"],
            "&source_path=",
            encoder.encode_uri_component(source_path),
            "&type=2",
            "&t=",
            util.timestamp(),
        ]
    )
    req = net.urlopen(url, headers={"Cookie": cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:BuddhismZhang,项目名称:bcloud,代码行数:25,代码来源:pcs.py


示例15: cloud_list_task

def cloud_list_task(cookie, tokens, start=0):
    """获取当前离线下载的任务信息
    
    start - 从哪个任务开始, 从0开始计数, 会获取这50条任务信息
    """
    url = "".join(
        [
            const.PAN_URL,
            "rest/2.0/services/cloud_dl?channel=chunlei&clienttype=0&web=1",
            "&bdstoken=",
            tokens["bdstoken"],
            "&need_task_info=1&status=255",
            "&start=",
            str(start),
            "&limit=50&method=list_task&app_id=250528",
            "&t=",
            util.timestamp(),
        ]
    )
    req = net.urlopen(url, headers={"Cookie": cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:BuddhismZhang,项目名称:bcloud,代码行数:25,代码来源:pcs.py


示例16: check_login

def check_login(cookie, token, username):
    """进行登录验证, 主要是在服务器上验证这个帐户的状态.

    如果帐户不存在, 或者帐户异常, 就不需要再进行最后一步的登录操作了.
    这一步有可能需要输入验证码.
    @return 返回errInfo.no, 如果为0, 表示一切正常, 可以登录.
    """
    url = "".join(
        [
            const.PASSPORT_URL,
            "?logincheck",
            "&token=",
            token,
            "&tpl=mm&apiver=v3",
            "&tt=",
            util.timestamp(),
            "&username=",
            encoder.encode_uri_component(username),
            "&isphone=false",
        ]
    )
    req = net.urlopen(url, headers={"Cookie": cookie.header_output()})
    if req:
        return json.loads(req.data.decode())
    else:
        return None
开发者ID:huangjiang2014,项目名称:bcloud,代码行数:26,代码来源:auth.py


示例17: get_category

def get_category(cookie, tokens, category, page=1):
    '''获取一个分类中的所有文件信息, 比如音乐/图片

    目前的有分类有:
      视频 - 1
      音乐 - 2
      图片 - 3
      文档 - 4
      应用 - 5
      其它 - 6
      BT种子 - 7
    '''
    timestamp = util.timestamp()
    url = ''.join([
        const.PAN_API_URL,
        'categorylist?channel=chunlei&clienttype=0&web=1',
        '&category=', str(category),
        '&pri=-1&num=100',
        '&t=', timestamp,
        '&page=', str(page),
        '&order=time&desc=1',
        '&_=', timestamp,
        '&bdstoken=', cookie.get('STOKEN').value,
        ])
    req = net.urlopen(url, headers={'Cookie': cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:blueyi,项目名称:bcloud,代码行数:30,代码来源:pcs.py


示例18: cloud_delete_task

def cloud_delete_task(cookie, tokens, task_id):
    """删除一个离线下载任务, 不管这个任务是否已完成下载.

    同时还会把它从下载列表中删除.
    """
    url = "".join(
        [
            const.PAN_URL,
            "rest/2.0/services/cloud_dl",
            "?bdstoken=",
            tokens["bdstoken"],
            "&task_id=",
            str(task_id),
            "&method=delete_task&app_id=250528",
            "&t=",
            util.timestamp(),
            "&channel=chunlei&clienttype=0&web=1",
        ]
    )
    req = net.urlopen(url, headers={"Cookie": cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:BuddhismZhang,项目名称:bcloud,代码行数:25,代码来源:pcs.py


示例19: cloud_cancel_task

def cloud_cancel_task(cookie, tokens, task_id):
    """取消离线下载任务.
    
    task_id - 之前建立离线下载任务时的task id, 也可以从cloud_list_task()里
              获取.
    """
    url = "".join(
        [
            const.PAN_URL,
            "rest/2.0/services/cloud_dl",
            "?bdstoken=",
            tokens["bdstoken"],
            "&task_id=",
            str(task_id),
            "&method=cancel_task&app_id=250528",
            "&t=",
            util.timestamp(),
            "&channel=chunlei&clienttype=0&web=1",
        ]
    )
    req = net.urlopen(url, headers={"Cookie": cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:BuddhismZhang,项目名称:bcloud,代码行数:26,代码来源:pcs.py


示例20: list_share

def list_share(cookie, tokens, uk, page=1):
    '''获取用户已经共享的所有文件的信息

    uk   - user key
    page - 页数, 默认为第一页.
    num  - 一次性获取的共享文件的数量, 默认为100个.
    '''
    num = 100
    start = 100 * (page - 1)
    url = ''.join([
        const.PAN_URL,
        'pcloud/feed/getsharelist?',
        '&t=', util.timestamp(),
        '&categor=0&auth_type=1&request_location=share_home',
        '&start=', str(start),
        '&limit=', str(num),
        '&query_uk=', str(uk),
        '&channel=chunlei&clienttype=0&web=1',
        '&bdstoken=', tokens['bdstoken'],
        ])
    req = net.urlopen(url, headers={
        'Cookie': cookie.header_output(),
        'Referer': const.SHARE_REFERER,
        })
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
开发者ID:lubing521,项目名称:bcloud,代码行数:29,代码来源:pcs.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python file.store_uploaded_file函数代码示例发布时间:2022-05-27
下一篇:
Python util.get_required_param函数代码示例发布时间: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