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


Python utils.timestamp函数代码示例

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


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

示例1: userLogin

 def userLogin(self, userId, userCookie,
         lastSeen = utils.timestamp(False),
         email = None, openid = None,
         firstName = None, lastName = None, cellPhone = None,
         memberSince = utils.timestamp(False), uType = 'manual'):
     cursor = self.__conn.cursor()
     try:
         uid = self.getUser(uid = userId, ck = userCookie)['_id']
         cursor.execute("""UPDATE """
                 + DbWorker.dbCfg['table.user'] +
                 """ 
                 SET _firstName = %s
                 , _lastName = %s
                 , _cellPhone = %s
                 , _lastSeen = %s
                 , _type = %s
                 , _cookie = %s
                  WHERE _id = %s
                 """ , (firstName, lastSeen,
                 cellPhone, lastSeen, uType, userCookie, uid))
     except RecordNotFound as e:
         cursor.execute("""
                 INSERT INTO """ + DbWorker.dbCfg['table.user'] + 
                 """ VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
                 """,
                 (userId,
                 email, openid, firstName, lastName, cellPhone,
                 memberSince, lastSeen, uType, userCookie))
     finally:
         self.__conn.commit()
         cursor.close()
开发者ID:prakharsharma,项目名称:thrifty,代码行数:31,代码来源:dbWorker.py

示例2: save_ignored_relationship

 def save_ignored_relationship(self, uid, tid):
     if not self.__ignored_relationship.get(uid):
         self.__ignored_relationship[uid] = [utils.timestamp(), [tid]]
     else:
         self.__ignored_relationship[uid][0] = utils.timestamp()
         self.__ignored_relationship[uid][1].append(tid)
         self.__ignored_relationship[uid][1] = self.__ignored_relationship[uid][1][-2:]
开发者ID:uhoohei,项目名称:texas,代码行数:7,代码来源:services.py

示例3: test_event_comment_notification

 def test_event_comment_notification(self):
     
     to_notify = self.make_user(username='noticeuser')
     
     self.register_for_notifications(user=to_notify)
     self.register_for_notifications()
     
     event = Event(**{
         u'where': 'test',
         u'when': timestamp(),
         u'what': 'test',
         u'broadcast': False,
         u'posted_from': [37.422834216666665, -122.08536667833332],
         u'creator': self.get_user()[u'username'],
     })
     event.save()
     
     Attendant(**{
         u'status': status.ATTENDING,
         u'timestamp': timestamp(),
         u'event': event[u'id'],
         u'user': to_notify[u'id'],
     }).save()
     
     comment = 'the test comment'
     
     response = self.post('/events/%s/comments/' % event[u'id'], 
                          {'comment': comment})
     self.assertEqual(response.status, 200, 'comments POST 200')
     
     nots = self.get_new_notifications(user=to_notify)
     
     self.assertEqual(len(nots), 1, 'one new notification')
     
     notification = nots[0]
     
     self.assertTrue(u'type' in notification, 
                     'poll response has type')
     self.assertEqual(notification[u'type'], 'comment', 
                      'event has the correct type')
     
     self.assertTrue(u'event_revision' in notification, 
                     'poll response has event rev')
     self.assertEqual(notification[u'event_revision'], event[u'revision'], 
                      'event has the correct revision')
     
     self.assertTrue(u'comment' in notification, 
                     'poll response has comment')
     self.assertEqual(notification[u'comment'], comment, 
                      'event has the correct comment')
     
     self.assertTrue(u'commenter' in notification, 
                     'poll response has commenter')
     self.assertEqual(notification[u'commenter'], self.get_user()[u'username'], 
                      'event has the correct commenter')
     
     nots = self.get_new_notifications()
     self.assertEqual(len(nots), 0, 'no notification for the poster')
开发者ID:Shopcaster,项目名称:Connectsy-Server,代码行数:58,代码来源:notification.py

示例4: get

def get(gkey,itm=[],start_time=0,stop_time=0,sort='clock asc',groupby=0,page=None):
	"""
	获取统计数据
	参数说明
	   itm itemid列表 为空时提取整个group的记录
	   start_time 开始时间戮
	   stop_time  结构时间戮
	   sort       排序方式 
	   groupby    分组方式 
	   page       分页参数集 {'site':每页数据量,'num':页码} 默认返回所有记录
	"""
	stat_db = mysqldb.get_db()
	rdb = rediswrap.get_redis()
	sql_item = {'fields':'*'}
	r_itmkey = RD_ITM_KEY_PRFX+gkey
	if itm:
		itm.append('mrk')
		itmids = rdb.hmget(r_itmkey,itm)
		mrk = itmids.pop().split(',')
		
	else:
		mrk = rdb.hget(r_itmkey,'mrk')
		itmids = rdb.hvals(r_itmkey)
		itmids.remove(mrk)
		mrk = mrk.split(',')	

	ids = [k for k in itmids if k ]	
	sql_item['table'] = get_hst_name(mrk[1]) 
	sql_item['where'] = " itemid in (%s) " % ",".join(ids)
	start_time = utils.timestamp(start_time) if start_time else utils.timestamp(0,'d')
	stop_time = utils.timestamp(stop_time) if stop_time else int(time.time())
	sql_item['where'] += " and clock>=%s and clock <%s" % (start_time,stop_time)
	sql_item['order'] = sort

	if groupby:
		if groupby ==1:
			sql_item['group'] = 'itemid'
		elif groupby == 2:
			sql_item['group'] = 'clock'
		else:
			sql_item['group'] = 'itemid,clock' 
		sql_item['fields'] = "itemid,sum(val) as val,clock"
	#分页这个mark一下。待定
	if page:
		s = page['num']*page['site']
		sql_item['limit'] = "%s,%s" %(s,page['site'])
	
	res,desc = stat_db.query(sql_item)
	#取得items的名称
	item_lab = {}
	if res == 0 and desc:
		itm_tb = "stat_item_" + mrk[0] if mrk[0] else "stat_item"
		rs, ds = stat_db.query("select name,id from %s where id in(%s)" %(itm_tb,",".join(ids) ))
		if rs==0 and ds:
			for row in ds :
				item_lab[row['id']]=row['name']
		return 0,[item_lab,desc]
	return 0,[{},[]]
开发者ID:alofiyin,项目名称:myoproject,代码行数:58,代码来源:stat_base.py

示例5: test_event_list_sort

    def test_event_list_sort(self):
        t1 = timestamp()
        t2 = timestamp()
        t3 = timestamp()
        
        e1 = Event(**{
            u'when': t1,
            u'what': 'user2 created, broadcast',
            u'broadcast': True,
            u'creator': self.get_user()[u'username'],
            u'created': t1,
        })
        e1.save()
        
        e2 = Event(**{
            u'when': t2,
            u'what': 'user2 created, broadcast',
            u'broadcast': True,
            u'creator': self.get_user()[u'username'],
            u'created': t3,
        })
        e2.save()
        
        e3 = Event(**{
            u'when': t2,
            u'what': 'user2 created, broadcast',
            u'broadcast': True,
            u'creator': self.get_user()[u'username'],
            u'created': t2,
        })
        e3.save()
        
        e4 = Event(**{
            u'when': t3,
            u'what': 'user2 created, broadcast',
            u'broadcast': True,
            u'creator': self.get_user()[u'username'],
            u'created': t1,
        })
        e4.save()
        
        response = self.get('/events/?sort=soon&filter=creator&'
                            'username=%s' % self.get_user()[u'username'])
        self.assertEqual(response.status, 200, 'response OK')
        
        events = json.loads(response.read())[u'events']
        self.assertEqual(len(events), 4, 'correct number of events returned')
        
        self.assertEqual(events[0], e1[u'revision'], 
                         'event 1 when correct, primary sort')
        #unconnect to test secondary sort
#        self.assertEqual(events[1], e3[u'revision'], 
#                         'event 3 when correct, secondary sort')
#        self.assertEqual(events[2], e2[u'revision'], 
#                         'event 2 when correct, secondary sort')
        self.assertEqual(events[3], e4[u'revision'], 
                         'event 4 when correct, primary sort')
开发者ID:Shopcaster,项目名称:Connectsy-Server,代码行数:57,代码来源:lists.py

示例6: test_event_list_invited

 def test_event_list_invited(self):
     user = self.get_user()
     user2 = self.make_user(username='user2')
     user3 = self.make_user(username='user3')
     
     self.follow(user, user2, reciprocal=True)
     self.follow(user3, user, reciprocal=True)
     
     event1 = Event(**{
         u'where': 'test',
         u'when': timestamp(),
         u'what': 'user2 created',
         u'broadcast': False,
         u'posted_from': [37.422834216666665, -122.08536667833332],
         u'creator': user2[u'username'],
     })
     event1.save()
     Attendant(user=user[u'id'], event=event1[u'id']).save()
     
     event2 = Event(**{
         u'where': 'test',
         u'what': 'user3 created',
         u'broadcast': False,
         u'creator': user3[u'username'],
     })
     event2.save()
     Attendant(user=user[u'id'], event=event2[u'id'], 
               status=status.ATTENDING).save()
     
     event3 = Event(**{
         u'where': 'test',
         u'what': 'user2 created, broadcast',
         u'broadcast': True,
         u'posted_from': [37.422834216666665, -122.08536667833332],
         u'creator': user2[u'username'],
     })
     event3.save()
     
     event4 = Event(**{
         u'where': 'test',
         u'when': timestamp(),
         u'what': 'user3 created',
         u'broadcast': False,
         u'creator': user3[u'username'],
     })
     event4.save()
     
     response = self.get('/events/?filter=invited')
     self.assertEqual(response.status, 200, 'response OK')
     
     events = json.loads(response.read())[u'events']
     
     self.assertEqual(len(events), 3, 'correct number of events returned')
     self.assertTrue(event1[u'revision'] in events, 'event 1 returned')
     self.assertTrue(event2[u'revision'] in events, 'event 2 returned')
     self.assertTrue(event3[u'revision'] in events, 'event 3 returned')
开发者ID:Shopcaster,项目名称:Connectsy-Server,代码行数:56,代码来源:lists.py

示例7: check_login

 def check_login(self, stage=0):
     # self.curl.request("http:/pan.baidu.com/")
     
     ret = self.api_request("https://pan.baidu.com/api/account/thirdinfo")
     if ret["errno"] == 0:
         logger.debug("Login check success!")
         return True
     
     # More than twice landing check
     if stage >= 2:
         logger.debug("Login check failed!")
         return False
     
     # Get token
     token = self.get_token()
     
     # Check require verifycode
     params = dict(token=token,
                   tpl="netdisk",
                   apiver="v3",
                   tt=utils.timestamp(),
                   username=self.username,
                   isphone="false")
     check_login_url = "https://passport.baidu.com/v2/api/?logincheck&" + urllib.urlencode(params)
     ret = self.api_request(check_login_url)
     code_string =  ret["data"]["codeString"]
     
     if code_string:
         logger.debug("Login check require verifycode")
         verifycode = self.get_verifycode(code_string)
     else:    
         verifycode = ""
         
     # try to login    
     login_params = dict(staticpage="http://pan.baidu.com/res/static/thirdparty/pass_v3_jump.html",
                         charset="utf-8",
                         token=token,
                         tpl="netdisk",
                         tt=utils.timestamp(),
                         codestring=code_string,
                         isPhone="false",
                         safeflg=0,
                         u="http://pan.baidu.com/",
                         username=self.username,
                         password=self.password,
                         verifycode=verifycode,
                         mem_pass="on",
                         )    
     login_url = "https://passport.baidu.com/v2/api/?login"
     html = self.curl.request(login_url, data=login_params, method="POST")
     url = re.findall(r"encodeURI\('(.*?)'\)", html)[0]
     self.curl.request(url)
     return self.check_login(stage + 1)
开发者ID:gerpayt,项目名称:BdFTP,代码行数:53,代码来源:disk.py

示例8: getLibrarySymbols

def getLibrarySymbols():
    global libSyms
    global wsSyms
    global wsLibs
    global scannerProcess
    global scanq
    if not libSyms:
        if not scanq:
            libSyms = {}
            wsSyms = {}
            wsLibs = {}
        else:
            utils.timestamp("Getting scan results from queue")
            (libSyms, wsSyms, wsLibs) = scanq.get()
            utils.timestamp("Done queue get")
        if scannerProcess:
            utils.timestamp("Joining scan process")
            scannerProcess.join()
            utils.timestamp("Done join")
        scannerProcess = None
        if scanq:
            scanq.close()
        scanq = None
        import symbolscanner

        symbolscanner.setInitialResults(workspacePath, libSyms, wsSyms, wsLibs)
    return libSyms
开发者ID:amirgeva,项目名称:coide,代码行数:27,代码来源:system.py

示例9: list

 def list(self, dir="/", page=1, num='15'):
     # None for error
     params = dict(channel='chunlei',
                   clienttype=0,
                   web=1,
                   num=num,
                   t=utils.timestamp(),
                   page=page,
                   dir=dir,
                   _=utils.timestamp())
     ret = self.api_request("http://pan.baidu.com/api/list", 
                            extra_data=params)
     files = ret['list']
     return files
开发者ID:gerpayt,项目名称:bdyimg,代码行数:14,代码来源:disk.py

示例10: test_event_notification_attending_creator

 def test_event_notification_attending_creator(self):
     
     to_attend = self.make_user(username='attending_user')
     
     self.register_for_notifications(user=self.get_user())
     
     event = Event(**{
         u'where': 'test',
         u'when': timestamp(),
         u'what': 'test',
         u'broadcast': False,
         u'posted_from': [37.422834216666665, -122.08536667833332],
         u'creator': self.get_user()[u'username'],
     })
     event.save()
     
     # this attendant will trigger the notification
     Attendant(**{
         u'status': status.INVITED,
         u'timestamp': timestamp(),
         u'event': event[u'id'],
         u'user': to_attend[u'id'],
     }).save()
     
     response = self.post('/events/%s/attendants/' % event[u'id'], 
                          {u'status': status.ATTENDING}, 
                          auth_user=to_attend)
     self.assertEqual(response.status, 200, 'attendants POST 200')
     
     nots = self.get_new_notifications(user=self.get_user())
     
     self.assertEqual(len(nots), 1, 'one new notification')
     
     notification = nots[0]
     
     self.assertTrue(u'type' in notification, 
                     'poll response has type')
     self.assertEqual(notification[u'type'], 'attendant', 
                      'event has the correct type')
     
     self.assertTrue(u'event_revision' in notification, 
                     'poll response has event rev')
     self.assertEqual(notification[u'event_revision'], event[u'revision'], 
                      'event has the corrrect revision')
     
     self.assertTrue(u'attendant' in notification, 
                     'poll response has attendant')
     self.assertEqual(notification[u'attendant'], to_attend[u'username'], 
                      'event has the corrrect attendant')
开发者ID:Shopcaster,项目名称:Connectsy-Server,代码行数:49,代码来源:notification.py

示例11: read_request_proxy

    def read_request_proxy(self, client_conn):
        line = self.get_line(self.rfile)
        if line == "":
            return None

        if not self.proxy_connect_state:
            connparts = http.parse_init_connect(line)
            if connparts:
                host, port, httpversion = connparts
                headers = self.read_headers(authenticate=True)
                self.wfile.write(
                            'HTTP/1.1 200 Connection established\r\n' +
                            ('Proxy-agent: %s\r\n'%self.server_version) +
                            '\r\n'
                            )
                self.wfile.flush()
                self.establish_ssl(client_conn, host, port)
                self.proxy_connect_state = (host, port, httpversion)
                line = self.rfile.readline(line)

        if self.proxy_connect_state:
            r = http.parse_init_http(line)
            if not r:
                raise ProxyError(400, "Bad HTTP request line: %s"%repr(line))
            method, path, httpversion = r
            headers = self.read_headers(authenticate=False)

            host, port, _ = self.proxy_connect_state
            content = http.read_http_body_request(
                self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit
            )
            return flow.Request(
                        client_conn, httpversion, host, port, "https", method, path, headers, content,
                        self.rfile.first_byte_timestamp, utils.timestamp()
                   )
        else:
            r = http.parse_init_proxy(line)
            if not r:
                raise ProxyError(400, "Bad HTTP request line: %s"%repr(line))
            method, scheme, host, port, path, httpversion = r
            headers = self.read_headers(authenticate=True)
            content = http.read_http_body_request(
                self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit
            )
            return flow.Request(
                        client_conn, httpversion, host, port, scheme, method, path, headers, content,
                        self.rfile.first_byte_timestamp, utils.timestamp()
                    )
开发者ID:billinghamj,项目名称:mitmproxy,代码行数:48,代码来源:proxy.py

示例12: make_logfile_name

def make_logfile_name(params=None, net_save_filename=None, timestamp = None, train=True):
    '''
    Returns the name of the logfile for the current training/forward pass run
    '''

    #Need to specify either a params object, or the net save prefix
    utils.assert_arglist(params,
        [net_save_filename])

    if params is not None:
        if train:
            _net_save_filename = params['train_save_net']
        else:
            _net_save_filename = params['output_prefix']

    if net_save_filename is not None:
        _net_save_filename = net_save_filename

    save_prefix = os.path.splitext( _net_save_filename )[0]

    save_prefix_valid = len(save_prefix) > 0
    assert(save_prefix_valid)

    if timestamp is None:
        timestamp = utils.timestamp()
    mode = "train" if train else "forward"

    directory_name = os.path.dirname( save_prefix )
    if not os.path.exists(directory_name):
        os.mkdir(directory_name)

    save_filename = "{}_{}_{}.log".format(save_prefix, mode, timestamp)

    return save_filename
开发者ID:BenJamesbabala,项目名称:znn-release,代码行数:34,代码来源:front_end.py

示例13: read_request_transparent

    def read_request_transparent(self, client_conn):
        orig = self.config.transparent_proxy["resolver"].original_addr(self.connection)
        if not orig:
            raise ProxyError(502, "Transparent mode failure: could not resolve original destination.")
        self.log(client_conn, "transparent to %s:%s"%orig)

        host, port = orig
        if port in self.config.transparent_proxy["sslports"]:
            scheme = "https"
            if not self.ssl_established:
                self.establish_ssl(client_conn, host, port)
        else:
            scheme = "http"
        line = self.get_line(self.rfile)
        if line == "":
            return None
        r = http.parse_init_http(line)
        if not r:
            raise ProxyError(400, "Bad HTTP request line: %s"%repr(line))
        method, path, httpversion = r
        headers = self.read_headers(authenticate=False)
        content = http.read_http_body_request(
                    self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit
                )
        return flow.Request(
                    client_conn,httpversion, host, port, scheme, method, path, headers, content,
                    self.rfile.first_byte_timestamp, utils.timestamp()
               )
开发者ID:jsoriano,项目名称:mitmproxy,代码行数:28,代码来源:proxy.py

示例14: _read_request_transparent

 def _read_request_transparent(self, client_conn, scheme, host, port):
     """
     Read a transparent HTTP request. Transparent means that the client isn't aware of proxying.
     In other words, the client request starts with
     "GET /foo.html HTTP/1.1"
     rather than
     "CONNECT example.com:80 HTTP/1.1"
     """
     if scheme.lower() == "https" and not self.ssl_established:
         self.establish_ssl(client_conn, host, port)
     line = self.get_line(self.rfile)
     if line == "":
         return None
     r = http.parse_init_http(line)
     if not r:
         raise ProxyError(400, "Bad HTTP request line: %s"%repr(line))
     method, path, httpversion = r
     headers = self.read_headers(authenticate=False)
     content = http.read_http_body_request(
                 self.rfile, self.wfile, headers, httpversion, self.config.body_size_limit
             )
     return flow.Request(
                 client_conn,httpversion, host, port, scheme, method, path, headers, content,
                 self.rfile.first_byte_timestamp, utils.timestamp()
            )
开发者ID:billinghamj,项目名称:mitmproxy,代码行数:25,代码来源:proxy.py

示例15: __init__

    def __init__(self, username, password):
        self.username = username
        self.password = password
        self.session = requests.session()

        # https://ss0.bdstatic.com/5LMZfyabBhJ3otebn9fN2DJv/passApi/js/login_tangram_f2e986d5.js


        # self.index_url = 'https://www.baidu.com/'

        # href="https://passport.baidu.com/v2/?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2F"
        # https://www.baidu.com/   主页
        # #https://passport.baidu.com/v2/?login   登录界面
        # get token
        # https://passport.baidu.com/v2/api/?getapi&tpl=pp&apiver=v3&tt=1431305718340&class=login&logintype=basicLogin&callback=bd__cbs__k7txq4

        ##
        ##要先访问主页,自动保存cookies ,再访问sign_url 才能显示页面内容
        self.sign_url = 'https://passport.baidu.com/v2/api/?login'
        # self.mission_url = 'http://v2ex.com/mission/daily'

        self.config_section = 'baidu'
        '''配置文件字段'''
        self.config_cookies = 'cookies'
        '''配置文件字段'''

        self.tt = utils.timestamp();
开发者ID:saiwei13,项目名称:mock_login,代码行数:27,代码来源:baidu.py


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