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

Python marshal.dumps函数代码示例

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

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



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

示例1: run_phase4

	def run_phase4(self):
		self.advance_phase()
		if self.am_leader():
			self.debug("Leader broadcasting ciphers to all nodes")
			self.broadcast_to_all_nodes(marshal.dumps(self.final_ciphers))
			self.debug("Cipher set len %d" % (len(self.final_ciphers)))
		else:
			""" Get C' ciphertexts from leader. """
			self.final_ciphers = marshal.loads(self.recv_from_leader())

		"""
		self.final_ciphers holds an array of
		pickled (round_id, cipher_prime) tuples
		"""

		my_cipher_str = marshal.dumps((self.round_id, self.cipher_prime))

		go = False
		if my_cipher_str in self.final_ciphers:
			self.info("Found my ciphertext in set")
			go = True
			self.debug("Go = TRUE")
		else:
			self.critical("ABORT! My ciphertext is not in set!")
			self.debug(self.final_ciphers)
			go = False
			self.debug("Go = FALSE")
			raise RuntimeError, "Protocol violation: My ciphertext is missing!"

		#Pedro: Directly copy the final ciphers (plaintext in coinshuffle)
		self.anon_data = self.final_ciphers
开发者ID:ecrypto,项目名称:shuffle,代码行数:31,代码来源:shuffle_node.py


示例2: prepare_value

def prepare_value(val, compress):
    flag = 0
    if isinstance(val, six.binary_type):
        pass
    elif isinstance(val, bool):
        flag = FLAG_BOOL
        val = str(int(val)).encode('utf-8')
    elif isinstance(val, six.integer_types):
        flag = FLAG_INTEGER
        val = str(val).encode('utf-8')
    elif isinstance(val, six.text_type):
        flag = FLAG_MARSHAL
        val = marshal.dumps(val, 2)
    else:
        try:
            val = marshal.dumps(val, 2)
            flag = FLAG_MARSHAL
        except ValueError:
            val = cPickle.dumps(val, -1)
            flag = FLAG_PICKLE

    if compress and len(val) > 1024:
        flag |= FLAG_COMPRESS
        val = quicklz.compress(val)

    return flag, val
开发者ID:douban,项目名称:dpark,代码行数:26,代码来源:beansdb.py


示例3: get_config

    def get_config(self):
        py3 = sys.version_info[0] == 3

        if isinstance(self.function, python_types.LambdaType):
            if py3:
                function = marshal.dumps(self.function.__code__).decode('raw_unicode_escape')
            else:
                function = marshal.dumps(self.function.func_code).decode('raw_unicode_escape')
            function_type = 'lambda'
        else:
            function = self.function.__name__
            function_type = 'function'

        if isinstance(self._output_shape, python_types.LambdaType):
            if py3:
                output_shape = marshal.dumps(self._output_shape.__code__)
            else:
                output_shape = marshal.dumps(self._output_shape.func_code)
            output_shape_type = 'lambda'
        elif callable(self._output_shape):
            output_shape = self._output_shape.__name__
            output_shape_type = 'function'
        else:
            output_shape = self._output_shape
            output_shape_type = 'raw'

        config = {'function': function,
                  'function_type': function_type,
                  'output_shape': output_shape,
                  'output_shape_type': output_shape_type,
                  'arguments': self.arguments}
        base_config = super(Lambda, self).get_config()
        return dict(list(base_config.items()) + list(config.items()))
开发者ID:basveeling,项目名称:keras,代码行数:33,代码来源:core.py


示例4: Paser_SigMDB

def Paser_SigMDB(file, num) :
    fp = open(SIGDB_FILENAME)

    while 1: 
        lines = fp.readlines(100000) #메모리가 허용하는 적당한 양 
        if not lines: 
            break 
        for line in lines: 
            convert(line, num)

    fp.close()

    fname = '%s.c%02d' % (file, num)
    output = open(fname, 'wb')
    #s = pickle.dumps(db_size_pattern, -1)
    s = marshal.dumps(db_size_pattern)
    output.write(s)
    output.close()

    fname = '%s.i%02d' % (file, num)
    output = open(fname, 'wb')
    # s = pickle.dumps(db_vname, -1)
    s = marshal.dumps(db_vname)
    output.write(s)
    output.close()
开发者ID:idkwim,项目名称:kicomav,代码行数:25,代码来源:sigtool.py


示例5: accept_phase

    def accept_phase(self, ip, port, nonce):
        # package and encrypt data
        response = marshal.dumps((nonce, self.ip, self.gui_port))
        cipher = AnonCrypto.sign_with_key(self.privKey, response)

        # respond with ((ip, port), encrypted_data)
        AnonNet.send_to_addr(ip, int(port), marshal.dumps(("accept", cipher)))
开发者ID:nya2,项目名称:Dissent-TCP-communication,代码行数:7,代码来源:net.py


示例6: split

  def split(self):
    """Split a RecordIORecordsZipped data into two even chunks.

    :return: lower_entries, higher_entries, middle_entry
    """
    new_zipped_chunks = list(self.get_zipped_chunks_())
    if len(new_zipped_chunks) <= 1:
      raise RecordIOTooSmallToSplitError()
    lo_chunks = []
    hi_chunks = []
    lo_size = 0
    hi_size = 0
    left = -1
    right = len(new_zipped_chunks)
    while left + 1 != right:
      if lo_size <= hi_size:
        left += 1
        lo_chunks.append(new_zipped_chunks[left])
        lo_size += len(new_zipped_chunks[left][2])
      else:
        right -= 1
        hi_chunks.insert(0, new_zipped_chunks[right])
        hi_size += len(new_zipped_chunks[right][2])
    middle_entry_lo = new_zipped_chunks[right][0]
    self.records_ = []
    self.zipped_chunks_ = lo_chunks + hi_chunks
    return (marshal.dumps(lo_chunks, MARSHAL_VERSION),
            marshal.dumps(hi_chunks, MARSHAL_VERSION),
            middle_entry_lo)
开发者ID:n-dream,项目名称:recordio,代码行数:29,代码来源:recordio_records_zipped.py


示例7: __init__

 def __init__(self, layers, function, output_shape=None):
     if len(layers) < 2:
         raise Exception("Please specify two or more input layers (or containers) to merge")
     self.layers = layers
     self.params = []
     self.regularizers = []
     self.constraints = []
     self.updates = []
     for l in self.layers:
         params, regs, consts, updates = l.get_params()
         self.regularizers += regs
         self.updates += updates
         # params and constraints have the same size
         for p, c in zip(params, consts):
             if p not in self.params:
                 self.params.append(p)
                 self.constraints.append(c)
     py3 = sys.version_info[0] == 3
     if py3:
         self.function = marshal.dumps(function.__code__)
     else:
         self.function = marshal.dumps(function.func_code)
     if output_shape is None:
         self._output_shape = None
     elif type(output_shape) in {tuple, list}:
         self._output_shape = tuple(output_shape)
     else:
         if py3:
             self._output_shape = marshal.dumps(output_shape.__code__)
         else:
             self._output_shape = marshal.dumps(output_shape.func_code)
开发者ID:nickfrosst,项目名称:keras,代码行数:31,代码来源:core.py


示例8: addSong

 def addSong(self,vid,imgURL,title,artist):
     if self.active:
         #print "adding"
         conn=sqlite3.connect(self.db)
         x=m.dumps([])
         y=m.dumps([])
         args=(vid,imgURL,title,artist,x,y,self.k,)
         c=conn.cursor()
             #raise e
         L=c.execute("SELECT * FROM songs WHERE videoid=? AND played=1 AND party=? ",(vid,self.k,)).fetchall()
         if len(L)==0:
             L=c.execute("SELECT * FROM songs WHERE videoid=? AND played=0 AND party=? ",(vid,self.k,)).fetchall()
             if len(L)==0:
                 c.execute("INSERT INTO songs (videoid,imgURL,name,artist,upvotes,downvotes,total,upvoteip,downvoteip,played,party) VALUES (?,?,?,?,0,0,0,?,?,0,?)",args)
                 conn.commit()
                 conn.close()
                 return
             else:
                 conn.close()
             #print "in queue!"
                 return "The song is already in the queue!"
         else:
             c.execute("REPLACE INTO songs (videoid,imgURL,name,artist,upvotes,downvotes,total,upvoteip,downvoteip,played,party) VALUES (?,?,?,?,0,0,0,?,?,0,?)",args)
         conn.commit()
         conn.close()
     else:
         return "Party not active."
开发者ID:y4smeen,项目名称:vynl-v0,代码行数:27,代码来源:party.py


示例9: upVote

    def upVote(self,vid, ip):
        if self.active:
            conn=sqlite3.connect(self.db)
            c=conn.cursor()
            num=c.execute("SELECT upvotes,total,upvoteip, downvotes, downvoteip FROM songs WHERE videoid=? AND party=?",(vid,self.k,)).fetchone()
            x=m.loads(num[2])
            y=m.loads(num[4])
            if ip not in x:
                if ip in y:
                    x.append(ip)
                    y.remove(ip)
                    x=m.dumps(x)
                    y=m.dumps(y)
                    c.execute("UPDATE songs SET upvotes=?, total=?, upvoteip=?, downvotes=?, downvoteip=? WHERE videoid=? AND party=",(num[0]+1,num[1]+2,x, num[3]-1,y,vid,self.k,))
                else:
                    x.append(ip)
                    x=m.dumps(x)
                    c.execute("UPDATE songs SET upvotes=?, total=?, upvoteip=? WHERE videoid=? AND party=?",(num[0]+1,num[1]+1,x,vid,self.k,))
            elif ip in x:
                x.remove(ip)
                x=m.dumps(x)
                c.execute("UPDATE songs SET upvotes=?, total=?, upvoteip=? WHERE videoid=? AND party=?",(num[0]-1,num[1]-1,x,vid,self.k,))

            conn.commit()
            conn.close()
        else:
            return "Party not active."
开发者ID:y4smeen,项目名称:vynl-v0,代码行数:27,代码来源:party.py


示例10: add

	def add(self, document, defer_recalculate = True):
		# Retreive (if known URI) or assign document ID
		known_ID = self.db.get('U_'+ document.uri)
		if known_ID:
			document.id = int(known_ID)
		else:
			self.max_id += 1
			self.db['M_max_id'] = str(self.max_id)
			document.id = self.max_id
			self.db["U_" + document.uri] = str(document.id)
		# Add an entry for each document's metadata
		tokens = document.tokens
		del(document.tokens) # we don't want to store these
		doc_details = document.__dict__
		modified = time.localtime(document.modified)
		doc_details['str_modified'] = time.strftime('%d %B %Y', modified)
		self.db["D_%s" % document.id] = marshal.dumps(doc_details)
		# Add/update the entry for each term in the document
		for term in tokens:
			if self.db.has_key('T_' + term):
				term_data = marshal.loads(self.db['T_' + term])
			else:
				term_data = {}
			term_data[document.id] = (tokens[term], document.length)
			# TODO: optimise by chunking db inserts
			self.db['T_' + term] = marshal.dumps(term_data)
开发者ID:tomdyson,项目名称:dolphy,代码行数:26,代码来源:index.py


示例11: setup_default_condor_setup

def setup_default_condor_setup():
	"""
	Checks that all users have a default condor setup in their profile (for every plugin).
	Already existing values will remain untouched, missing default setup will be added.
	"""
	logger.setGroup('condor', 'Checking that all users have a default condor setup in their profile')
	users = User.objects.all()
	for user in users:
		p = user.get_profile()
		if len(p.dflt_condor_setup) == 0:
			# No default Condor setup rules
			logger.log("Missing Condor setup in %s's profile" % user.username)
			setup = {}
			for plugin in manager.plugins:
				# Default is to use the ALL policy
				setup[plugin.id] = {'DB': 'policy', 'DS': '', 'DP': 'ALL'}
			p.dflt_condor_setup = base64.encodestring(marshal.dumps(setup)).replace('\n', '')
			p.save()
			logger.log("Added default Condor setup rules for %s" % user.username)
		else:
			# Ok, existing but maybe default rules for some (newly created?) plugins are missing
			setup = marshal.loads(base64.decodestring(p.dflt_condor_setup))
			updated = False
			for plugin in manager.plugins:
				if not setup.has_key(plugin.id):
					setup[plugin.id] = {'DB': 'policy', 'DS': '', 'DP': 'ALL'}
					updated = True
			p.dflt_condor_setup = base64.encodestring(marshal.dumps(setup)).replace('\n', '')
			p.save()
			if updated:
				logger.log("Updated default Condor setup rules for %s" % user.username)
			else:
				logger.log("Default Condor setup rules for %s look good" % user.username)
开发者ID:gotsunami,项目名称:Youpi,代码行数:33,代码来源:checksetup.py


示例12: prepare_value

def prepare_value(val, compress):
    flag = 0
    if isinstance(val, str):
        pass
    elif isinstance(val, (bool)):
        flag = FLAG_BOOL
        val = str(int(val))
    elif isinstance(val, (int, long)):
        flag = FLAG_INTEGER
        val = str(val)
    elif isinstance(val, unicode):
        flag = FLAG_MARSHAL
        val = marshal.dumps(val, 2)
    else:
        try:
            val = marshal.dumps(val, 2)
            flag = FLAG_MARSHAL
        except ValueError:
            val = cPickle.dumps(val, -1)
            flag = FLAG_PICKLE

    if compress and len(val) > 1024:
        flag |= FLAG_COMPRESS
        val = quicklz.compress(val)

    return flag, val
开发者ID:windreamer,项目名称:dpark,代码行数:26,代码来源:beansdb.py


示例13: save_all_2

    def save_all_2(self):
        if self.settings.no_save != "True":
            print("Writing dictionary...")

            try:
                zfile = zipfile.ZipFile(self.brain_path, 'r')
                for filename in zfile.namelist():
                    data = zfile.read(filename)
                    f = open(filename, 'w+b')
                    f.write(data)
                    f.close()
            except (OSError, IOError):
                print("no zip found. Is the programm launch for first time ?")

            with open("words.dat", "wb") as f:
                f.write(marshal.dumps(self.words))

            with open("lines.dat", "wb") as f:
                f.write(marshal.dumps(self.lines))

            # save the version
            with open('version', 'w') as f:
                f.write(self.saves_version)

            # zip the files
            with zipfile.ZipFile(self.brain_path, "w") as f:
                f.write('words.dat')
                f.write('lines.dat')
                f.write('version')

            try:
                os.remove('words.dat')
                os.remove('lines.dat')
                os.remove('version')
            except (OSError, IOError):
                print("could not remove the files")

            f = open("words.txt", "w")
            # write each words known
            wordlist = []
            # Sort the list befor to export
            for key in self.words.keys():
                wordlist.append([key, len(self.words[key])])
            wordlist.sort(key=lambda x: x[1])
            list(map((lambda x: f.write(str(x[0]) + "\n\r")), wordlist))
            f.close()

            f = open("sentences.txt", "w")
            # write each words known
            wordlist = []
            # Sort the list befor to export
            for key in self.unfilterd.keys():
                wordlist.append([key, self.unfilterd[key]])
            # wordlist.sort(lambda x, y: cmp(y[1], x[1]))
            wordlist.sort(key=lambda x: x[1])
            list(map((lambda x: f.write(str(x[0]) + "\n")), wordlist))
            f.close()

            # Save settings
            self.settings.save()
开发者ID:jrabbit,项目名称:pyborg-1up,代码行数:60,代码来源:pyborg.py


示例14: encode_function

def encode_function(function):
  if type(function) != types.BuiltinFunctionType:
    builtin = False
    return marshal.dumps(((function.func_code, capture_globals(function)), builtin))
  else:
    builtin = True
    return marshal.dumps((function.__name__, builtin))
开发者ID:helfer,项目名称:py-rdd,代码行数:7,代码来源:util.py


示例15: get_group_buy_info

    def get_group_buy_info(self):
        _infos = yield redis.hgetall(DICT_GROUP_BUY_INFO)
        if not _infos:
            _group_buy_info = {1:0,2:0,3:0,4:0}  #buy_type:buy_num
            for buy_type in xrange(1,5):
                yield redis.hset(DICT_GROUP_BUY_INFO, buy_type, dumps(_group_buy_info[buy_type]))
        else:
            _group_buy_info = dict()
            for k, v in _infos.iteritems():
                _group_buy_info[k] = loads(v)

        _res = []
        _ret = []
        for _buy_type, _bought_num in _group_buy_info.iteritems():
           _res.append([_buy_type, _bought_num])

        _stream = yield redis.hget(DICT_GROUP_BUY_PERSON_INFO, self.cid)#[[buy_count, [status,2,3,4]],..]
        if _stream:
            try:
                _data = loads(_stream)
                if _data:
                    # [bought_count, [0,0,0,0]]
                    for _bought_count_info, _info in zip(_data, _res):
                        _info.append(_bought_count_info)
                        _ret.append(_info)
            except:
                log.exception()
        else:
            _value = [[0,[0,0,0,0]]] * 4
            yield redis.hset(DICT_GROUP_BUY_PERSON_INFO, self.cid, dumps(_value))
            for _info in _res:
                _info.append([0,[0,0,0,0]])
                _ret.append(_info)
        defer.returnValue( _ret )
开发者ID:anson-tang,项目名称:3dkserver,代码行数:34,代码来源:gsexcite_activity.py


示例16: buy_group_package

 def buy_group_package(self, buy_type):
     if buy_type not in get_group_buy_conf().keys():
         defer.returnValue( BUY_GROUP_TYPE_WRONG )
     _conf = get_group_buy_conf(buy_type)
     _stream = yield redis.hget(DICT_GROUP_BUY_PERSON_INFO, self.cid)
     _data = loads(_stream)
     #[[buy_count, [0,0,0,0]], ......]
     bought_count, _info = _data[buy_type-1]
     if bought_count + 1 > _conf["LimitNum"]:
         defer.returnValue(GROUP_BUY_MAX_COUNT)
     if self.user.credits < _conf["CurrentPrice"]:
         defer.returnValue(CHAR_CREDIT_NOT_ENOUGH)
     yield self.user.consume_credits(_conf["CurrentPrice"], WAY_GROUP_BUY)
     bought_count +=1
     _st = yield redis.hget(DICT_GROUP_BUY_INFO, buy_type)
     _datas = loads(_st)
     #buy_type:buy_num
     _total_buy_count = _datas
     if bought_count == 1:
         _total_buy_count += 1
     _data[buy_type-1] = [bought_count, _info]
     yield redis.hset(DICT_GROUP_BUY_PERSON_INFO, self.cid, dumps(_data))
     yield redis.hset(DICT_GROUP_BUY_INFO, buy_type, dumps(_total_buy_count))
     _item_type, _item_id, _item_num = _conf['ItemType'], _conf['ItemID'], _conf['ItemNum']
     _res = yield item_add(self.user, ItemType=_item_type, ItemID=_item_id, ItemNum = _item_num, AddType=WAY_GROUP_BUY)
     _result = (buy_type, _total_buy_count, bought_count, _res[1][0], self.user.credits)
     defer.returnValue( _result )
开发者ID:anson-tang,项目名称:3dkserver,代码行数:27,代码来源:gsexcite_activity.py


示例17: pass1

def pass1(arg):
    """
  Chunk files into a doc->term mapping,
  and simultaneously build a term->df count.
  The term->df counts are redistributed to
  buckets via python's in-built hash function.
  This is basically an inversion step, so that 
  now we are chunked on the term axis rather
  than the document axis.
  """
    global __maxorder, __b_freq, __b_list, __locks
    chunk_id, chunk_paths = arg

    extractor = Tokenizer(__maxorder)
    term_doc_freq = defaultdict(int)
    term_doc_list = defaultdict(list)

    for doc_index, path in enumerate(chunk_paths):
        with open(path) as f:
            tokenset = set(extractor(f.read()))
            for token in tokenset:
                term_doc_freq[token] += 1
                term_doc_list[token].append(doc_index)

    for key in term_doc_freq:
        bucket_index = hash(key) % len(__locks)
        with __locks[bucket_index]:
            os.write(__b_freq[bucket_index], marshal.dumps((key, term_doc_freq[key])))
            os.write(__b_list[bucket_index], marshal.dumps((key, chunk_id, term_doc_list[key])))

    return len(term_doc_freq)
开发者ID:ekmutai,项目名称:langid.py,代码行数:31,代码来源:LDfeatureselect.py


示例18: test_floats

    def test_floats(self):
        # Test a few floats
        small = 1e-25
        n = sys.maxint * 3.7e250
        while n > small:
            for expected in (-n, n):
                f = float(expected)
                s = marshal.dumps(f)
                got = marshal.loads(s)
                self.assertEqual(f, got)
                marshal.dump(f, file(test_support.TESTFN, "wb"))
                got = marshal.load(file(test_support.TESTFN, "rb"))
                self.assertEqual(f, got)
            n /= 123.4567

        f = 0.0
        s = marshal.dumps(f)
        got = marshal.loads(s)
        self.assertEqual(f, got)

        n = sys.maxint * 3.7e-250
        while n < small:
            for expected in (-n, n):
                f = float(expected)
                s = marshal.dumps(f)
                got = marshal.loads(s)
                self.assertEqual(f, got)
                marshal.dump(f, file(test_support.TESTFN, "wb"))
                got = marshal.load(file(test_support.TESTFN, "rb"))
                self.assertEqual(f, got)
            n *= 123.4567
        os.unlink(test_support.TESTFN)
开发者ID:bushuhui,项目名称:pyKanjiDict,代码行数:32,代码来源:test_marshal.py


示例19: fetchData

def fetchData():
    global od
    global pw
    global lc
    #--------------------
    # Set your Telemachus server's IP address here and only here.
    #--------------------
    ip = "192.168.1.40:8085"

#    url = "http://" + str(ip) + "/telemachus/datalink?long=v.long"
    url = "http://" + str(ip) + "/telemachus/datalink?throt=f.throttle&rcs=v.rcsValue&sas=v.sasValue&light=v.lightValue&pe=o.PeA&ap=o.ApA&ttap=o.timeToAp&ttpe=o.timeToPe&operiod=o.period&sma=o.sma&alt=v.altitude&hat=v.heightFromTerrain&mt=v.missionTime&sfcs=v.surfaceSpeed&sfcv=v.surfaceVelocity&sfcvx=v.surfaceVelocityx&sfcvy=v.surfaceVelocityy&sfcvz=v.surfaceVelocityz&ov=v.orbitalVelocity&vs=v.verticalSpeed&lat=v.lat&long=v.long&body=v.body&o2=r.resource[Oxygen]&co2=r.resource[CarbonDioxide]&h2o=r.resource[Water]&w=r.resource[ElectricCharge]&food=r.resource[Food]&waste=r.resource[Waste]&wastewater=r.resource[WasteWater]&mo2=r.resourceMax[Oxygen]&mco2=r.resourceMax[CarbonDioxide]&mh2o=r.resourceMax[Water]&mw=r.resourceMax[ElectricCharge]&mfood=r.resourceMax[Food]&mwaste=r.resourceMax[Waste]&mwastewater=r.resourceMax[WasteWater]&pitch=n.pitch&roll=n.roll&hdg=n.heading&pstat=p.paused&inc=o.inclination&ecc=o.eccentricity&aoe=o.argumentOfPeriapsis&lan=o.lan&ut=t.universalTime&lf=r.resource[LiquidFuel]&oxidizer=r.resource[Oxidizer]&mono=r.resource[MonoPropellant]&mlf=r.resourceMax[LiquidFuel]&moxidizer=r.resourceMax[Oxidizer]&mmono=r.resourceMax[MonoPropellant]"
    try:
        u = urllib2.urlopen(url)
        d = json.load(u)
        od = d
        if d["w"] >= pw:
            lc = d["mt"]
        d["lc"] = lc
        d["wr"] = d["w"] - pw
        pw = d["w"]
        bytes = marshal.dumps(d)
        print "Got! :)"
    except:
        print "Didn't got :("
        bytes = marshal.dumps(od)
    return bytes
开发者ID:PeterGrand,项目名称:kspmc,代码行数:26,代码来源:getdata.py


示例20: send_monthly_card_reward

def send_monthly_card_reward():
    conn = MySQLdb.connect(**db_conf)
    cursor = conn.cursor()

    cid_sql = 'select id, monthly_card from tb_character' 
    update_sql = 'update tb_character set monthly_card = %s where id = %s'

    print 'send begin!'
    
    cursor.execute( cid_sql )
    _all_cid = cursor.fetchall()
    for _cid, _month in _all_cid:
        if _month:
            _month -= 1
            if _month == 0:
                yield redis.hdel(redis_key, _cid)
            else:
                card_data = (time(), 0)
                yield redis.hset(redis_key, _cid, dumps(card_data))
            _primary = yield redis.hincrby( 'HASH_HINCRBY_KEY', 'AWARD_ID', 1 )
            _data    = [_primary, 4, [time()]]
            yield redis.hset( 'HASH_AWARD_CENTER_%s' % _cid, _primary, dumps(_data) )
            cursor.execute(update_sql % (_month, _cid))

    cursor.close()
    conn.close()
 
    print 'end...'
    conn   = None
    cursor = None
    reactor.stop()
开发者ID:anson-tang,项目名称:3dkserver,代码行数:31,代码来源:send_month_reward.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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