def update_from_json(jsonstr): """JSONからマスターデータに保存. """ data = Json.decode(jsonstr) model_mgr = ModelRequestMgr() modellist = [] for cls_id in xrange(MasterData.MASTER_NUM_MAX): model_cls = MasterData.CLASSES.get(cls_id) if model_cls is None: raise CabaretError("Not Found:%d" % cls_id, CabaretError.Code.INVALID_MASTERDATA) clsname = model_cls.__name__ arr = data.get(clsname) or [] for dic in arr: ins = model_cls() for k, v in dic.items(): setattr(ins, k, v) model_mgr.set_save(ins) modellist.append(ins) def tr(): model_mgr.write_all() db_util.run_in_transaction_custom_retries(0, tr) model_mgr.write_end() MasterData.incrementEditCacheVersion() return modellist
def responseToData(self, response): json_obj = Json.decode(response) entry = json_obj['entry'] if type(entry) is list: return [self.dictdataToPeople(data) for data in entry] else: return self.dictdataToPeople(entry)
def handle(self, *args, **options): print '================================' print 'present_eventticket' print '================================' if settings_sub.IS_DEV: s = "[[97, 50]]" else: s = "[[38, 2], [74, 1], [85, 2], [147, 2], [235, 1], [259, 4], [314, 21], [331, 4], [526, 2], [551, 12], [739, 1], [748, 2], [849, 2], [864, 4], [976, 3], [981, 2], [991, 1], [1039, 2], [1045, 2], [1093, 10], [1219, 2], [1227, 3], [1272, 5], [1279, 2], [1443, 2], [1475, 1], [1476, 1], [1527, 5], [1593, 3], [1658, 2], [1705, 61], [1804, 7], [1805, 11], [1915, 105], [1929, 133], [1984, 1], [1993, 5], [2044, 248], [2052, 3], [2190, 1], [2235, 101], [2239, 3], [2242, 2], [2259, 5], [2295, 2], [2404, 45], [2551, 125], [2557, 238], [2561, 10], [2567, 2], [2594, 1], [2654, 5], [2664, 1], [2696, 36], [2824, 2], [2825, 17], [2857, 248], [2907, 5], [2909, 6], [2941, 3], [2983, 4], [3063, 7], [3122, 13], [3173, 3], [3456, 4], [3481, 2], [3800, 24], [3885, 24], [4007, 6], [4049, 88], [4148, 2], [4167, 43], [4316, 16], [4373, 3], [4386, 33], [4397, 1], [4404, 1], [4410, 3], [4432, 5], [4610, 2], [4653, 1], [4725, 4], [4776, 56], [4779, 2], [4806, 1], [4858, 2], [4882, 21], [4893, 1], [4953, 7], [5014, 3], [5037, 1], [5055, 4], [5075, 2], [5171, 2], [5178, 100], [5183, 2], [5279, 2], [5311, 3], [5318, 6], [5339, 2], [5400, 2], [5515, 1], [5553, 5], [5600, 4], [5980, 1], [6059, 3], [6138, 1], [6181, 2], [6191, 1], [6313, 1], [6380, 9], [6396, 2], [6397, 2], [6482, 8], [6505, 5], [6535, 1], [6558, 2], [6574, 1], [6584, 10], [6671, 10], [6845, 7], [6915, 1], [6995, 1], [6998, 176], [7095, 3], [7116, 2], [7220, 2], [7351, 175], [7395, 1], [7440, 3], [7515, 1], [7537, 2], [7559, 2], [7666, 4], [7668, 2], [7683, 3], [7751, 1], [7825, 4], [7860, 1], [7864, 2], [7950, 1], [8045, 1], [8174, 1], [8186, 95], [8248, 12], [8458, 1], [8487, 13], [8563, 7], [8566, 1], [8638, 2], [8723, 14], [8739, 1], [8757, 3], [8823, 2], [8926, 7], [8968, 3], [8996, 5], [9005, 1], [9013, 1], [9056, 2], [9060, 1], [9162, 1], [9209, 4], [9345, 2], [9410, 1], [9503, 1], [9536, 1], [9614, 1], [9784, 6], [9867, 6], [9878, 2], [9927, 3], [9935, 1], [10004, 7], [10057, 1], [10096, 1], [10187, 1], [10192, 4], [10197, 15], [10208, 3], [10226, 4], [10229, 1], [10242, 18], [10315, 2], [10445, 6], [10460, 2], [10480, 3], [10490, 9], [10616, 3], [10627, 4], [10813, 8], [11248, 14], [11386, 2], [11664, 1], [11748, 2], [11865, 4], [11969, 2], [12075, 4], [12096, 5], [12229, 3], [12270, 5], [12480, 39], [12482, 9], [12564, 6], [12565, 1], [12722, 7], [12815, 13], [12950, 1], [13069, 5], [13076, 10], [13157, 19], [13268, 10], [13425, 4], [13442, 18], [13501, 7], [13591, 112], [13627, 5], [13633, 1], [13803, 3], [13926, 4], [13957, 21], [14112, 15], [14203, 2], [14493, 64], [14818, 3], [14871, 2], [15092, 2], [15102, 18], [15198, 4], [15326, 1], [15451, 1], [15537, 4], [15714, 6], [15824, 60], [15937, 8], [15942, 2], [15966, 1], [16014, 7], [16078, 2], [16113, 72], [16134, 1], [16277, 18], [16290, 22], [16465, 11], [16523, 9], [16612, 9], [16675, 1], [16681, 2], [16716, 310], [16829, 7], [16948, 18], [17189, 2], [17281, 1], [17408, 130], [17444, 1], [17519, 3], [17605, 3], [17786, 50], [17847, 1], [17911, 10], [17928, 259], [18261, 5], [18336, 5], [18481, 3], [18506, 12], [18515, 1], [18673, 1], [18755, 4], [18983, 2], [19030, 2], [19252, 3], [19326, 10], [19698, 4], [19713, 9], [19850, 1], [19888, 19], [20018, 4], [20054, 2], [20122, 45], [20444, 9], [20472, 4], [20527, 1], [20609, 3], [20767, 4], [20823, 17], [20850, 2], [21063, 1], [21113, 2], [21149, 10], [21212, 43], [21235, 10], [21263, 6], [21298, 7], [21304, 3], [21364, 12], [21392, 3], [21396, 1], [21422, 5], [21491, 1], [21510, 50], [21597, 42], [21738, 4], [21836, 2], [22076, 2], [22147, 5], [22374, 28], [22685, 2], [22693, 3], [22705, 11], [22840, 5], [22859, 3], [22921, 4], [22944, 9], [22954, 10], [22956, 39], [22976, 23], [22995, 2], [23160, 4], [23178, 2], [23279, 37], [23509, 3], [23557, 26], [23672, 2], [23745, 193], [23759, 3], [23915, 2], [24071, 7], [24213, 3], [24305, 1], [24432, 7], [24757, 3], [24807, 13], [24869, 1], [24952, 9], [25064, 1], [25147, 105], [25299, 4], [25353, 39], [25655, 1], [25723, 7], [25809, 1], [25843, 2], [25852, 2], [26098, 50], [26351, 1], [26555, 2], [26624, 1], [26716, 1], [26917, 15], [27354, 1], [27431, 7], [27455, 3], [27468, 2], [27549, 10], [27576, 419], [27581, 2], [27638, 33], [27699, 2], [27732, 4], [27771, 11], [27800, 1], [27865, 6], [27985, 2], [28050, 3], [28069, 3], [28146, 4], [28276, 165], [28405, 2], [28480, 3], [28506, 75], [28534, 2], [28703, 1], [28763, 2], [28804, 279], [28941, 2], [28949, 6], [28971, 2], [28990, 6], [29006, 1], [29024, 2], [29056, 54], [29581, 7], [29840, 4], [29895, 2], [29923, 1], [29932, 8], [30034, 7], [30079, 5], [30087, 1], [30092, 4], [30174, 50], [30214, 15], [30215, 18], [30223, 2], [30278, 2], [30291, 2], [30330, 9], [30421, 7], [30489, 10], [30582, 21], [30588, 2], [30602, 379], [30605, 5], [30632, 2], [30661, 5], [30668, 1], [30709, 395], [30710, 2], [30724, 10], [30755, 7], [30763, 2], [30808, 4], [30819, 2], [30932, 1], [30938, 2], [30990, 2], [30991, 4], [31065, 3], [31088, 5], [31117, 339], [31152, 2], [31285, 1], [31520, 2], [31627, 8], [31671, 1], [31756, 632], [31764, 3], [31786, 2], [31876, 5], [31893, 8], [32033, 8], [32070, 1], [32194, 2], [32232, 2], [32243, 2], [32275, 6], [32282, 5], [32336, 2], [32367, 32], [32373, 8], [32413, 4], [32426, 3], [32460, 4], [32504, 2], [32521, 2], [32597, 40], [32659, 74], [32682, 2], [32720, 1], [32810, 12], [32891, 40], [32893, 1], [33004, 1], [33440, 4], [33554, 20], [33599, 2], [33739, 2], [33748, 8], [33753, 5], [33808, 4], [33815, 3], [33911, 17], [33914, 6], [33928, 6], [33954, 9], [33961, 80], [33982, 7], [34068, 6], [34126, 659], [34481, 1], [34509, 4], [34535, 2], [34554, 2], [34759, 9], [34935, 1], [34995, 5], [35032, 25], [35042, 10], [35049, 1], [35141, 1], [35244, 15], [35369, 1], [35379, 6], [35418, 1], [35578, 1], [35608, 4], [35640, 160], [35658, 7], [35674, 2], [35707, 2], [35738, 1], [35761, 482], [35768, 23], [35775, 3], [35885, 2], [36028, 1], [36096, 5], [36105, 2], [36117, 3], [36131, 7], [36248, 5], [36322, 8], [36329, 15], [36618, 2], [36624, 5], [36805, 2], [36829, 3], [36863, 14], [36879, 2], [36945, 11], [36954, 14], [37034, 319], [37074, 2], [37391, 2], [37425, 50], [37470, 110], [37604, 13], [37833, 255], [37918, 19], [37919, 2], [37992, 6], [38101, 2], [38246, 2], [38325, 68], [38392, 2], [38485, 2], [38497, 26], [38644, 3], [38660, 1], [38678, 1], [38853, 8], [38971, 1], [39036, 1], [39213, 4], [39266, 2], [39497, 2], [39691, 5], [39770, 1], [39828, 2], [39914, 15], [40091, 2], [40099, 10], [40109, 2], [40176, 3], [40225, 2], [40297, 5], [40615, 3], [40662, 6], [40852, 1], [41016, 12], [41018, 3], [41023, 13], [41070, 1], [41103, 23], [41230, 2], [41436, 33], [41461, 26], [41571, 2], [41615, 276], [41632, 5], [41818, 4], [41855, 25], [41932, 3], [42000, 26], [42108, 49], [42358, 1], [42387, 5], [42402, 9], [42456, 2], [42534, 1], [42572, 2], [42589, 67], [42666, 13], [42766, 4], [43010, 4], [43015, 4], [43161, 2], [43171, 364], [43210, 2], [43274, 3], [43373, 3], [43427, 2], [43487, 6], [43738, 2], [44073, 1], [44101, 2], [44143, 80], [44306, 4], [44331, 2], [44389, 3], [44660, 2], [44673, 3], [44700, 5], [44835, 7], [44936, 2], [44970, 2], [45122, 1], [45409, 3], [45570, 6], [45600, 6], [45690, 26], [45708, 53], [45844, 2], [45899, 1], [46028, 2], [46219, 2], [46238, 12], [46261, 6], [46278, 1], [46543, 26], [46565, 2], [46634, 2], [46717, 3], [46750, 4], [46802, 4], [47075, 14], [47250, 3], [47694, 273], [47790, 3], [47866, 16], [47871, 16], [47969, 1], [48071, 15], [48093, 17], [48302, 278], [48390, 3], [48524, 164], [48779, 3], [48838, 53], [48856, 2], [48865, 16], [48869, 2], [48880, 4], [49106, 20], [49170, 3], [49177, 6], [49211, 1], [49338, 14], [49345, 4], [49349, 1], [49363, 4], [49492, 9], [49844, 25], [49895, 3], [49930, 2], [49958, 63], [50024, 4], [50246, 9], [50435, 101], [50441, 15], [50605, 3], [50643, 3], [50718, 39], [50748, 8], [50969, 1], [51051, 2], [51059, 4], [51178, 3], [51256, 1], [51287, 210], [51635, 1], [51967, 6], [51998, 2], [52170, 5], [52241, 3], [52340, 4], [52445, 2], [52447, 5], [52544, 12], [52551, 1], [52568, 35], [52656, 2], [52704, 9], [52751, 8], [52769, 1], [52969, 25], [53194, 1], [53198, 11], [53358, 9], [53663, 48], [53939, 1], [54114, 12], [54569, 2], [54793, 7], [54990, 2], [55122, 8], [55186, 200], [55643, 4], [55710, 3], [55743, 30], [55905, 2], [55981, 2], [56069, 76], [56103, 28], [56125, 24], [56239, 5], [56315, 1], [56554, 25], [56635, 2], [56761, 2], [56770, 3], [56803, 2], [56836, 70], [56893, 2], [56942, 11], [56944, 3], [57136, 2], [57227, 27], [57289, 73], [57355, 6], [57356, 2], [57478, 3], [57760, 2], [57777, 4], [57842, 83], [57919, 508], [58368, 2], [58585, 2], [58634, 5], [58669, 2], [58671, 323], [58694, 1], [58705, 1], [59004, 2], [59154, 82], [59267, 1], [59466, 10], [59576, 2], [59672, 4], [59786, 2], [60034, 1], [60265, 2], [60320, 17], [60322, 5], [60430, 47], [60485, 42], [60511, 2], [60655, 20], [61091, 9], [61101, 4], [61134, 57], [61464, 15], [61777, 284], [61886, 1], [61959, 4], [62092, 8], [62121, 2], [62172, 2], [62323, 258], [62375, 370], [62391, 2], [62419, 2], [62426, 5], [62697, 1], [62856, 5], [63101, 2], [63114, 4], [63115, 30], [63144, 84], [63181, 1], [63240, 9], [63326, 1], [63336, 275], [63430, 4], [63450, 6], [63494, 10], [63738, 2], [63824, 11], [63911, 2], [64150, 13], [64243, 9], [64312, 2], [64410, 25], [64437, 3], [64510, 4], [64515, 258], [64737, 2], [64743, 6], [64912, 2], [64937, 14], [64994, 18], [65039, 4], [65070, 6], [65114, 3], [65267, 276], [65332, 2], [65351, 9], [65371, 10], [65524, 5], [65552, 14], [65555, 2], [65600, 1], [65881, 14], [66089, 68], [66239, 45], [66255, 2], [66365, 39], [66410, 2], [66445, 2], [66574, 7], [66879, 1], [67005, 2], [67035, 3], [67233, 1], [67454, 338], [67475, 10], [67515, 3], [67554, 2], [67677, 4], [67739, 1], [67909, 15], [68065, 3], [68183, 9], [68437, 2], [68764, 2], [68773, 3], [68800, 2], [68883, 12], [68984, 2], [69085, 2], [69154, 5], [69187, 2], [69374, 3], [69507, 4], [69565, 573], [69769, 2], [69876, 294], [69885, 8], [69908, 3], [69990, 2], [70235, 2], [70236, 2], [70256, 6], [70385, 1], [70472, 374], [70630, 2], [70847, 15], [71042, 8], [71081, 2], [71099, 6], [71108, 1], [71217, 5], [71365, 3], [71441, 1], [71684, 3], [71773, 40], [71803, 2], [72144, 3], [72176, 4], [72290, 1], [72333, 2], [72357, 35], [72600, 15], [72805, 2], [72876, 5], [73097, 5], [73279, 2], [73303, 9], [73390, 3], [73458, 15], [73565, 2], [73646, 2], [73717, 3], [73794, 30], [73832, 2], [73939, 6], [74016, 5], [74097, 2], [74124, 1], [74233, 25], [74418, 2], [74519, 13], [74543, 12], [74550, 35], [74801, 24], [74866, 36], [75043, 4], [75083, 1], [75203, 1], [75281, 3], [75285, 4], [75345, 2], [75385, 4], [75547, 10], [75651, 2], [75776, 432], [76037, 6], [76059, 371], [76149, 2], [76156, 9], [76185, 5], [76413, 2], [76631, 2], [76756, 11], [76767, 1], [76796, 149], [76836, 151], [76890, 6], [77117, 46], [77158, 5], [77190, 1], [77222, 25], [77264, 60], [77398, 789], [77417, 1], [77455, 30], [77911, 6], [78005, 1], [78143, 2], [78157, 17], [78208, 20], [78890, 2], [78940, 1], [79015, 2], [79081, 49], [79247, 5], [79393, 4], [79492, 21], [79704, 2], [79728, 2], [79772, 3], [79959, 6], [79995, 3], [80018, 1], [80114, 8], [80137, 81], [80547, 11], [80551, 14], [80609, 2], [80707, 4], [80711, 12], [80721, 2], [80734, 53], [80835, 544], [81052, 2], [81289, 1], [81310, 2], [81507, 2], [81586, 1], [81777, 384], [81804, 23], [81834, 3], [82249, 1], [82382, 5], [82386, 7], [82390, 6], [82523, 353], [82576, 2], [82646, 2], [82675, 17], [82686, 7], [82748, 2], [82751, 271], [82857, 7], [82876, 2], [82903, 1], [83087, 5], [83149, 1], [83178, 1], [83243, 4], [83460, 3], [83473, 1], [83498, 2], [83532, 5], [83828, 10], [83907, 1], [83985, 2], [84000, 2], [84018, 6], [84057, 234], [84309, 286], [84338, 2], [84483, 2], [84907, 1], [84930, 40], [85267, 41], [85269, 2], [85364, 1], [85418, 2], [85568, 6], [85814, 2], [85891, 4], [85919, 1], [86053, 3], [86143, 12], [86203, 3], [86239, 3], [86263, 2], [86361, 4], [86396, 311], [86505, 16], [86892, 3], [87006, 7], [87082, 3], [87204, 5], [87333, 19], [87352, 7], [87357, 4], [87476, 2], [87605, 1], [87905, 9], [88066, 169], [88161, 1], [88249, 1], [88258, 64], [88293, 7], [88319, 7], [88344, 108], [88554, 6], [88618, 1], [88621, 2], [88703, 2], [88721, 22], [88824, 17], [88947, 1], [89021, 79], [89049, 80], [89153, 5], [89237, 120], [89243, 2], [89284, 11], [89349, 2], [89692, 2], [89704, 2], [89709, 6], [89753, 27], [89780, 6], [89820, 2], [89849, 2], [89865, 7], [90014, 14], [90041, 13], [90150, 2], [90329, 3], [90620, 20], [90686, 1], [90708, 1], [90860, 3], [90873, 12], [90927, 4], [91465, 3], [91492, 7], [91535, 5], [91797, 1], [91957, 4], [92031, 20], [92062, 105], [92081, 33], [92154, 2], [92386, 4], [92639, 1], [92851, 1], [92985, 17], [93114, 2], [93141, 204], [93298, 4], [93584, 3], [93892, 2], [93915, 2], [93953, 23], [94041, 37], [94060, 2], [94186, 4], [94240, 1], [94330, 8], [94392, 2], [94409, 1], [94450, 3], [94506, 1], [94509, 3], [94516, 9], [94546, 7], [94591, 155], [94609, 10], [94762, 24], [94836, 11], [94930, 44], [94946, 6], [95157, 6], [95195, 51], [95238, 2], [95349, 18], [95430, 42], [95557, 17], [95618, 2], [95636, 3], [95672, 4], [95703, 6], [95919, 2], [95924, 5], [95933, 3], [96015, 4], [96057, 3], [96060, 7], [96187, 6], [96252, 2], [96277, 3], [96360, 1], [96379, 2], [96520, 2], [96622, 10], [96711, 18], [96754, 47], [96982, 4], [97200, 2], [97417, 143], [97465, 6], [97519, 16], [97605, 9], [97632, 4], [97781, 6], [97810, 2], [97839, 1], [98087, 3], [98131, 3], [98134, 3], [98307, 2], [98387, 5], [98413, 1], [98494, 2], [98527, 2], [98598, 1], [98702, 110], [98800, 2], [99078, 1], [99149, 10], [99168, 1], [99218, 2], [99228, 6], [99237, 2], [99261, 12], [99352, 5], [99355, 2], [99585, 7], [99723, 6], [99765, 3], [99773, 6], [99791, 13], [99813, 2], [99837, 7], [99860, 207], [100309, 2], [100368, 1], [100404, 1], [100407, 170], [100410, 2], [100505, 12], [100616, 60], [100641, 6], [100649, 4], [100869, 2], [101020, 67], [101088, 33], [101154, 80], [101330, 2], [101543, 2], [101561, 2], [101597, 1], [101811, 7], [101869, 20], [102080, 9], [102333, 7], [102338, 2], [102356, 1], [102521, 3], [102814, 3], [102870, 3], [102884, 26], [102911, 21], [103206, 1], [103221, 3], [103264, 12], [103279, 3], [103665, 3], [103726, 4], [103867, 1], [104198, 5], [104312, 12], [104603, 99], [104804, 4], [104821, 35], [104855, 2], [104864, 3], [104878, 1], [104998, 29], [105095, 1], [105264, 1], [105306, 17], [105338, 1], [105360, 89], [105415, 1], [105661, 83], [105779, 5], [105907, 24], [106022, 5], [106030, 5], [106138, 1], [106148, 5], [106250, 3], [106367, 4], [106469, 2], [106525, 14], [106567, 5], [106615, 28], [106621, 200], [106735, 44], [106742, 3], [106751, 1], [106760, 25], [106770, 5], [106823, 3], [106854, 7], [106972, 3], [107042, 13], [107059, 15], [107088, 4], [107130, 2], [107181, 2], [107284, 4], [107781, 3], [107894, 30], [107955, 2], [108067, 4], [108250, 5], [108330, 67], [108448, 1], [108484, 3], [108638, 8], [108754, 4], [108771, 6], [108820, 2], [109022, 40], [109038, 6], [109161, 1], [109209, 2], [109272, 4], [109642, 8], [109746, 1], [109753, 3], [109924, 10], [110487, 234], [110703, 27], [110727, 5], [111055, 20], [111133, 5], [111137, 9], [111213, 9], [111285, 1], [111400, 4], [111408, 4], [111416, 5], [111507, 8], [111520, 2], [111620, 3], [111857, 3], [111943, 17], [112034, 2], [112079, 35], [112191, 1], [112276, 2], [112313, 98], [112431, 1], [112556, 27], [112726, 6], [112835, 5], [112868, 1], [113035, 3], [113062, 40], [113219, 2], [113270, 11], [113346, 4], [113423, 39], [113460, 4], [113533, 238], [113799, 2], [113828, 5], [113887, 4], [113940, 2], [114016, 3], [114251, 1], [114385, 6], [114439, 1], [114595, 11], [114765, 260], [114860, 1], [114936, 8], [114976, 88], [115007, 2], [115090, 19], [115198, 6], [115225, 3], [115341, 8], [115356, 1], [115441, 2], [115695, 65], [115703, 2], [115749, 5], [115808, 89], [115820, 47], [115861, 10], [115890, 13], [115969, 2], [115977, 3], [115987, 2], [116090, 41], [116183, 14], [116204, 12], [116255, 7], [116531, 2], [116709, 10], [116821, 150], [116875, 2], [116877, 26], [116906, 3], [116991, 1], [117180, 5], [117206, 2], [117255, 1], [117264, 17], [117334, 2], [117363, 1], [117395, 1], [117498, 3], [117713, 3], [117776, 6], [117954, 1], [117972, 17], [117984, 1], [117987, 2], [118045, 5], [118081, 19], [118105, 3], [118171, 2], [118277, 2], [118425, 19], [118463, 5], [118495, 17], [118498, 5], [118643, 5], [118669, 2], [118691, 3], [118697, 12], [118733, 1], [118876, 30], [119341, 14], [119356, 1], [119572, 2], [119606, 24], [119771, 2], [119855, 8], [119911, 4], [120090, 8], [120157, 2], [120242, 40], [120263, 3], [120378, 3], [120408, 3], [120477, 19], [120575, 2], [120606, 3], [120617, 2], [120672, 17], [120762, 2], [120849, 4], [120862, 2], [120893, 1], [121123, 4], [121320, 5], [121341, 1], [121394, 6], [121454, 15], [121496, 84], [121599, 69], [121951, 4], [121972, 11], [122020, 4], [122091, 3], [122108, 1], [122161, 1], [122177, 16], [122215, 1], [122328, 3], [122431, 4], [122530, 1], [122576, 2], [122633, 1], [122671, 2], [122796, 3], [122873, 2], [122910, 11], [122911, 6], [123086, 3], [123132, 2], [123151, 23], [123182, 39], [123192, 16], [123198, 2], [123307, 1], [123324, 10], [123391, 29], [123660, 3], [123761, 2], [123825, 1], [124413, 2], [124457, 2], [124578, 27], [124714, 2], [124768, 7], [124792, 2], [124845, 1], [124901, 216], [124924, 12], [124969, 4], [125058, 5], [125078, 1], [125083, 7], [125311, 4], [125436, 2], [125495, 2], [125510, 5], [125538, 3], [125539, 6], [125550, 2], [125756, 150], [125782, 9], [125820, 267], [125893, 2], [125998, 11], [126023, 1], [126051, 2], [126119, 16], [126128, 68], [126189, 2], [126222, 5], [126253, 4], [126338, 30], [126345, 12], [126590, 1], [126608, 5], [126913, 2], [126937, 1], [126966, 2], [126981, 1], [127115, 2], [127153, 14], [127169, 1], [127188, 2], [127254, 23], [127516, 5], [127597, 5], [127626, 2], [127667, 3], [127761, 2], [128102, 4], [128184, 13], [128204, 6], [128206, 2], [128336, 1], [128378, 2], [128386, 10], [128528, 2], [128585, 1], [128768, 7], [128829, 3], [128925, 2], [128977, 2], [128987, 2], [129010, 13], [129040, 1], [129261, 1], [129328, 3], [129343, 4], [129371, 4], [129418, 1], [129442, 10], [129444, 3], [129446, 1], [129459, 1], [129471, 4], [129848, 1], [129970, 298], [130032, 2], [130089, 4], [130165, 1], [130202, 2], [130241, 10], [130316, 11], [130395, 4], [130581, 157], [130586, 1], [130736, 2], [130763, 70], [131135, 2], [131186, 2], [131319, 4], [131344, 1], [131357, 2], [131373, 2], [131538, 24], [131824, 4], [131913, 2], [131925, 1], [131947, 386], [131997, 1], [132141, 1], [132150, 2], [132159, 1], [132164, 1], [132374, 2], [132390, 7], [132434, 235], [132492, 3], [132530, 3], [132746, 16], [132765, 4], [132843, 10], [132893, 1], [133021, 33], [133125, 2], [133152, 15], [133173, 2], [133245, 5], [133280, 51], [133397, 1], [133433, 2], [133616, 1], [133963, 2], [134003, 2], [134006, 2], [134062, 1], [134168, 2], [134202, 2], [134306, 3], [134318, 6], [134515, 1], [134597, 1], [134637, 1], [134745, 3], [134875, 6], [134959, 1], [134983, 12], [135097, 9], [135215, 9], [135265, 2], [135323, 421], [135399, 1], [135489, 1], [135562, 1], [135586, 2], [135798, 10], [135844, 2], [135863, 1], [135870, 2], [135894, 2], [136063, 5], [136144, 6], [136265, 4], [136449, 4], [136610, 5], [136763, 6], [136814, 2], [136844, 8], [136875, 25], [136924, 4], [136990, 9], [137000, 2], [137013, 1], [137150, 9], [137372, 2], [137777, 2], [137939, 2], [138238, 5], [138239, 79], [138309, 1], [138375, 2], [138416, 3], [138486, 7], [138691, 19], [138735, 2], [138771, 1], [138820, 1], [138884, 3], [138929, 2], [138944, 5], [138990, 1], [139052, 1], [139088, 2], [139589, 1], [139615, 2], [139733, 3], [139742, 2], [139747, 1], [139772, 1], [139825, 2], [139843, 4], [140070, 2], [140192, 1], [140224, 3], [140359, 2], [140434, 2], [140445, 10], [140449, 6], [140618, 7], [140666, 1], [141000, 56], [141422, 2], [141467, 3], [141687, 11], [141721, 2], [141834, 1], [141921, 2], [142104, 2], [142329, 2], [142514, 2], [142592, 1], [142823, 2], [142947, 1], [143022, 2], [143568, 1], [143601, 2], [143699, 6], [143789, 2], [143840, 4], [143875, 1], [144038, 1], [144094, 2], [144152, 2], [144207, 2], [144229, 5], [144320, 1], [144347, 4], [144448, 4], [144528, 1], [144653, 2], [144677, 2], [144740, 1], [144741, 2], [144806, 2], [144852, 2], [144902, 2], [144922, 4], [144929, 5], [145057, 3], [145077, 4], [145376, 2], [145453, 2], [145537, 1], [145624, 1], [145656, 4], [145755, 1], [145770, 1], [145899, 1], [146028, 1], [146045, 4], [146118, 1], [146130, 1], [146148, 1], [146248, 1], [146302, 6], [146420, 1], [146614, 1], [146701, 1], [147050, 1], [147507, 1], [147580, 1], [147652, 2], [147690, 3], [148054, 1]]" TARGET_LIST = Json.decode(s) config = BackendApi.get_current_raideventconfig(ModelRequestMgr()) print "event=%s" % config.mid for uid, num in TARGET_LIST: def tr(uid, mid, num): model_mgr = ModelRequestMgr() BackendApi.tr_add_raidevent_ticket(model_mgr, uid, mid, num) model_mgr.write_all() return model_mgr db_util.run_in_transaction(tr, uid, config.mid, num).write_end() print "%s=>%s" % (uid, num) print '================================' print 'all done..'
def responseToData(self, response): json_obj = Json.decode(response) status = json_obj.get('status', 'NG') message = json_obj.get('message', 'Message Empty') return { 'status': status, 'message': message, 'is_success': status == 'OK', 'data': response, }
def responseToData(self, response): json_obj = Json.decode(response) entry = json_obj['entry'] if type(entry) is not list: entry = [entry] datalist = [] for dictdata in entry: inspection = _dictdataToInspectionData(dictdata) if inspection: datalist.append(inspection) return datalist
def responseToData(self, response): json_obj = Json.decode(response) entry = json_obj['entry'] payment = PaymentPostResultData() payment._paymentId = entry.get('paymentId') payment._status = entry.get('status') payment._transactionUrl = entry.get('transactionUrl') payment._orderedTime = entry.get('orderedTime') payment.lock() return payment
def to_python(self, value): """ loadsしてみて成功したら結果を返す。 失敗したらそのまま返す。 """ if isinstance(value, unicode): value = StrUtil.to_s(value) if isinstance(value, str): try: value = Json.decode(value) except: pass return value
def run(cls, API): logger = DbgLogger() result = False apitest = None try: apitest = cls() apitest.setUp() OSAUtil.get_cache_client().flush() # キャッシュを消しておく. apitest.__api_name = API print 'API name:%s' % API query_params = { '_test': 1, OSAUtil.KEY_APP_ID: '119733', } query_params.update(apitest.get_query_params()) frompagedata = apitest.get_frompagedata() if frompagedata is not None: frompage_name, frompage_params = frompagedata frompage = FromPageUtil() frompage.setParams(frompage_name, frompage_params) query_params[Defines.URLQUERY_FROM] = '%s' % frompage print 'request query_params:%s' % query_params args = apitest.get_args() print 'request args:%s' % args res = cls.__sendRequest('%s%s' % (API, apitest.get_urlargs()), args, query_params) print "response:%s" % res if res: apitest.response = Json.decode(res) else: apitest.response = {} if 'log' in apitest.response: print "\nLog:" print apitest.response['log'] try: apitest.check() except AppTestError, e: print u'AppTestError: %s' % (e.value) print '!!!!!!!!!!!!!! NG !!!!!!!!!!!!!!' except Exception, e: # print e info = sys.exc_info() print AppError.makeErrorTraceString(info) print '!!!!!!!!!!!!!! NG !!!!!!!!!!!!!!'
def work(osa_util, url, body, http_method, headers): if settings_sub.IS_LOCAL: timeout = None else: timeout = 3 if settings_sub.USE_LOG: handler.addlog('Promotion Headers:') for k, v in headers.items(): handler.addlog(' %s=%s' % (k, v)) try: tmp = osa_util.httpopen(url, body, http_method, headers, timeout=timeout) response = tmp.read() return Json.decode(response) except urllib2.HTTPError, err: raise CabaretError(u'Promotion HTTPError:%s' % err)
def responseToData(self, response): json_obj = Json.decode(response) entry = json_obj['entry'] payment = PaymentData() payment._paymentId = entry.get('paymentId') payment._appId = entry.get('appId') payment._userId = self.requestdata.guid payment._status = entry.get('status') payment._callbackUrl = entry.get('callbackUrl') payment._finishPageUrl = entry.get('finishPageUrl') payment._transactionUrl = entry.get('transactionUrl') payment._message = entry.get('message') payment._orderedTime = entry.get('orderedTime') payment._executeTime = entry.get('executedTime') payment._paymentItems = tuple([self.dictdataToPaymentItem(dictdata) for dictdata in entry.get('paymentItems', [])]) payment.lock() return payment
def procPost(self): """ 決済確認. """ # 決済情報の確認. if settings_sub.IS_LOCAL: sku_id = self.request.get('_sku_id') buynum = self.request.get('_count') v_player = self.getViewerPlayer() payment_id = "%s%s" % (v_player.dmmid, OSAUtil.makeSessionID()) else: # JSONフォーマットで返ってくるので生のPOSTデータにアクセス #body = Json.decode(self.request.django_request.raw_post_data) body = Json.decode(self.request.django_request.body) self.json_param['ITEMS'] = body.get('ITEMS') self.json_param['PAYMENT_TYPE'] = body.get('PAYMENT_TYPE') self.json_param['PAYMENT_ID'] = body.get('PAYMENT_ID') self.json_param['ORDERER_TIME'] = body.get('ORDERER_TIME') sku_id = self.json_param['ITEMS'][0].get('SKU_ID') buynum = self.json_param['ITEMS'][0].get('COUNT') payment_id = self.json_param['PAYMENT_ID'] # 'SH' or 'GA' data_type = sku_id[:2] mid = sku_id[2:] if data_type == Handler.PAYMENT_TYPE_SHOP: # ショップ self.procShopDo(mid, buynum, payment_id) elif data_type == Handler.PAYMENT_TYPE_GACHA: # ガチャ self.procGachaDo(mid, buynum, payment_id) else: raise CabaretError(u'存在しない商品です', CabaretError.Code.INVALID_MASTERDATA) if not self.response.isEnd: self.response.set_status(200) self.response.send('{"response_code":"OK"}')
def responseToData(self, response): json_obj = Json.decode(response) entry = json_obj.get('entry') self.osa_util.logger.info('ignorelist entry:%s' % entry) if entry is None: self.osa_util.logger.info('ignorelist is None') return None elif not isinstance(entry, list): entry = [entry] datalist = [] for dictdata in entry: ignorelist = IgnorelistData() ignorelist._id = dictdata.get('id') ignorelist._ignorelistId = dictdata.get('ignorelistId') ignorelist.lock() datalist.append(ignorelist) return datalist
def __proc_update(self): """動画更新. 本番環境のみ. ステージングから指定した動画を受け取って各メディアサーバに配付する. """ if not settings_sub.IS_LOCAL and settings_sub_props.ENVIRONMENT_TYPE != settings_sub_props.EnvironmentType.MANAGER: self.response.set_status(404) return zf = None try: # ダウンロードするマスターデータ. try: filename = self.request.get('_name') except: self.response.set_status(400) return # ダウンロード元. url = settings_sub.MEDIA_DOWNLOAD_FROM + 'cabaret/mgr/movie/' headers = { "Content-type": "application/x-www-form-urlencoded", } body = urllib.urlencode({ '_name': filename, '_proc': 'package', }) try: response = self.osa_util.httpopen(url, body, 'POST', headers) data = response.read() except: raise def writeFile(filepath, data): f = None try: f = open(filepath, 'w') f.write(data) f.close() f = None except: if f: f.close() f = None raise io = StringIO(data) zf = ZipFile(io, 'r') # 動画ファイル. namelist = zf.namelist()[:] # マスターデータ. jsonfile = zf.open('master.json') obj_master = Json.decode(jsonfile.read()) namelist.remove('master.json') master = MoviePlayList.getValues(filters={'filename': filename}) if master: obj_master['id'] = master.id mid = obj_master['id'] # プレイリスト. m3u8filename = Media.movie_m3u8(filename) m3u8file = zf.open(m3u8filename) m3u8lines = [] for line in m3u8file.readlines(): s = line.rstrip('\n').rstrip('\r') if line.startswith('#EXT-X-KEY:METHOD=AES-128'): diff = len(line) - len(s) postfix = '' if 0 < diff: postfix = line[-diff:] url = self.makeAppLinkWebGrobalUrl( UrlMaker.movie_keyget(mid)) line = '#EXT-X-KEY:METHOD=AES-128,URI="%s"%s' % (url, postfix) m3u8lines.append(line) m3u8data = ''.join(m3u8lines) writeFile(os.path.join(settings_sub.MEDIA_DOC_ROOT, m3u8filename), m3u8data) namelist.remove(m3u8filename) # その他動画ファイル. dirpath = os.path.join(settings_sub.MEDIA_DOC_ROOT, filename) if not os.path.exists(dirpath): os.mkdir(dirpath) for name in namelist: outname = name if name == 'stream.ts': if settings_sub.IS_LOCAL: outname = filename + name else: continue filepath = os.path.join(dirpath, outname) data = zf.open(name).read() writeFile(filepath, data) zf.close() zf = None # マスターデータ書き込み. # 上書き. def tr(data): model_mgr = ModelRequestMgr() def forUpdate(model, inserted): for k, v in data.items(): setattr(model, k, v) model_mgr.add_forupdate_task(MoviePlayList, mid, forUpdate) model_mgr.write_all() return model_mgr tmp = db_util.run_in_transaction(tr, obj_master) tmp.write_end() # 配布. weblist = self.getMediaWebList() if weblist: errlog = MovieUtil.distribute(filename, weblist, settings_sub.SERVER_PASS) if errlog: raise CabaretError(errlog) # とり直しておく. model_mgr = self.getModelMgr() model_mgr.get_mastermodel_all(MoviePlayList, fetch_deleted=True, using=settings.DB_DEFAULT, reflesh=True) except: if zf: zf.close() zf = None raise self.putAlertToHtmlParam(u'動画を更新しました:name=%s' % filename, AlertCode.SUCCESS)
def __proc_update_pc(self): """動画更新(PC). 本番環境のみ. ステージングから指定した動画を受け取って本番Wowzaサーバに配付する. サムネイル画像は各メディアサーバに配付する. """ if not settings_sub.IS_LOCAL and settings_sub_props.ENVIRONMENT_TYPE != settings_sub_props.EnvironmentType.MANAGER: self.response.set_status(404) return zf = None try: # ダウンロードするマスターデータ. try: filename = self.request.get('_name') except: self.response.set_status(400) return # ダウンロード元. url = settings_sub.MEDIA_DOWNLOAD_FROM + 'cabaret/mgr/movie/' headers = { "Content-type": "application/x-www-form-urlencoded", } body = urllib.urlencode({ '_name': filename, '_proc': 'packagepc', }) try: response = self.osa_util.httpopen(url, body, 'POST', headers) data = response.read() except: raise def writeFile(filepath, data): f = None try: f = open(filepath, 'w') f.write(data) f.close() f = None except: if f: f.close() f = None raise io = StringIO(data) zf = ZipFile(io, 'r') # 動画ファイル. namelist = zf.namelist()[:] # マスターデータ. jsonfile = zf.open('master.json') obj_master = Json.decode(jsonfile.read()) namelist.remove('master.json') master = PcMoviePlayList.getValues(filters={'filename': filename}) if master: obj_master['id'] = master.id mid = obj_master['id'] mediadir = os.path.join(settings_sub.MEDIA_DOC_ROOT, filename) if not os.path.exists(mediadir): os.mkdir(mediadir) # 動画ファイル. mp4filename = Media.movie_mp4(filename) mp4data = zf.open(mp4filename).read() filepath = os.path.join(settings_sub.MEDIA_DOC_ROOT, mp4filename) writeFile(filepath, mp4data) namelist.remove(mp4filename) # サムネイル画像. dirpath = settings_sub.MEDIA_DOC_ROOT if not os.path.exists(dirpath): os.mkdir(dirpath) name = Media.movie_pc_thumbnail(filename) filepath = os.path.join(dirpath, name) data = zf.open(name).read() writeFile(filepath, data) zf.close() zf = None # マスターデータ書き込み. # 上書き. def tr(data): model_mgr = ModelRequestMgr() def forUpdate(model, inserted): for k, v in data.items(): setattr(model, k, v) model_mgr.add_forupdate_task(PcMoviePlayList, mid, forUpdate) model_mgr.write_all() return model_mgr tmp = db_util.run_in_transaction(tr, obj_master) tmp.write_end() # 配布. weblist = self.getMediaWebList() if weblist: # TODO errlog = MovieUtil.distribute_pc(filename, weblist, settings_sub.SERVER_PASS) if errlog: raise CabaretError(errlog) # 本番環境ではステージングと同じ動画を見るので配付する必要がない. if settings_sub.IS_DEV: errlog = MovieUtil.distribute_wowza(filename) if errlog: raise CabaretError(errlog) # とり直しておく. model_mgr = self.getModelMgr() model_mgr.get_mastermodel_all(PcMoviePlayList, fetch_deleted=True, using=settings.DB_DEFAULT, reflesh=True) except: if zf: zf.close() zf = None raise self.putAlertToHtmlParam(u'動画を更新しました:name=%s' % filename, AlertCode.SUCCESS)
def __proc_release(self): """本番環境. """ args = self.getUrlArgs('/master_data/') proc = args.get(0) table = { 'package' : self.__proc_package, 'download' : self.__proc_download, 'update' : self.__proc_update, } f = table.get(proc) if f: f() if self.response.isEnd: return url = settings_sub.MASTER_DOWNLOAD_FROM + 'cabaret/mgr' + UrlMaker.master_data('listget') jsonobj = {} try: response = self.osa_util.httpopen(url, None, 'GET', {}) jsonobj = Json.decode(response.read()) except: raise # 現在のマスターデータ. def callback(zf): data = None if zf: filenamepath = os.path.join(self.getDirectoryPath(), 'stg_filename.txt') if os.path.exists(filenamepath): try: f = open(filenamepath) name = f.read() f.close() except: if f: f.close() raise else: name = u'不明' data = { 'name' : name, 'ctime' : zf.open('createtime.txt').read(), 'url_download' : self.makeAppLinkUrlAdmin(OSAUtil.addQuery(UrlMaker.master_data('package'), '_name', 'current_master.zip')), } return data self.html_param['cur_zipfile'] = self.zipfile('current_master.zip', callback) ziplist = jsonobj.get('result', {}).get('zipfilelist', []) arr = [] for zipfile_obj in ziplist: name = zipfile_obj['name'] ctime = zipfile_obj['ctime'] arr.append({ 'name' : name, 'ctime' : ctime, }) self.html_param['zipfilelist'] = arr self.html_param['url_update'] = self.makeAppLinkUrlAdmin(UrlMaker.master_data('update')) self.html_param['url_download'] = self.makeAppLinkUrlAdmin(UrlMaker.master_data('download')) self.writeAppHtml('masterdata/release')
def responseToData(self, response): json_obj = Json.decode(response) entry = json_obj['entry'][0] return _dictdataToInspectionData(entry)
def handle(self, *args, **options): print '================================' print 'make_serial_code' print '================================' CODE = 'EKY2J8P4BFLWMQZ0UX915HC73NVGAS6TR' PATTERN_NUM_MAX = 42618442977 INTERVAL = 3163483 OFFSET_1 = 12061 OFFSET_2 = 14206147659 # 個数. num = int(args[0]) # 出力先. writer = Command.Writer(args[1]) # index. index_filepath = os.path.join( os.path.dirname(__file__), '../../../../../../../tool/serial_index') lap = 0 index = 0 if os.path.exists(index_filepath): f = open(index_filepath, 'r') strjson = f.read() f.close() obj = Json.decode(strjson) lap, index = obj print 'Start from...lap=%d, index=%d' % (lap, index) def compress(v, length): s = intCompress(v, base=CODE) if length < len(s): raise 'OverFlow!!' s = '%s%s' % (CODE[0] * length, s) return s[-length:] # シリアル作成. serials = {} for _ in xrange(num): v0 = random.randint(0, 1088) v1 = ((index + OFFSET_1) * INTERVAL) % PATTERN_NUM_MAX v2 = ((index + OFFSET_2) * INTERVAL) % PATTERN_NUM_MAX s0 = compress(v0, 2) s1 = compress(v1, 7) s2 = compress(v2, 7) s = s0 + s1 + s2 if serials.has_key(s): raise 'dupplicate...' serials[s] = True writer.add(s) index += 1 if PATTERN_NUM_MAX <= index: raise 'index over...' writer.output(overwrite=False) # indexを保存. print '================================' strjson = Json.encode([lap, index]) print 'write index...%s' % strjson f = open(index_filepath, 'w') f.write(strjson) f.close() print '================================' print 'all done..'
def __proc_list(self): """ファイル一覧. """ dirpath = settings_sub.MEDIA_DOC_ROOT if not os.path.exists(dirpath): os.mkdir(dirpath) model_mgr = self.getModelMgr() masterlist = BackendApi.get_movieplaylist_all( model_mgr, using=settings.DB_READONLY) masterdict = dict([(master.filename, master) for master in masterlist]) pcmasterlist = BackendApi.get_pcmovieplaylist_all( model_mgr, using=settings.DB_READONLY) pcmasterdict = dict([(master.filename, master) for master in pcmasterlist]) another_env_movies = {} another_env_pcmovies = {} downloadable = False if settings_sub.MEDIA_DOWNLOAD_FROM is not None: # 動画ダウンロード元. url = settings_sub.MEDIA_DOWNLOAD_FROM + 'cabaret/mgr' + UrlMaker.movie_edit( ) headers = { "Content-type": "application/x-www-form-urlencoded", } body = urllib.urlencode({'_proc': 'listget'}) jsonobj = {} response_data = None try: response = self.osa_util.httpopen(url, body, 'POST', headers) response_data = response.read() jsonobj = Json.decode(response_data) downloadable = True except: if response_data: raise CabaretError(response_data) raise for data in jsonobj.get('result', {}).get('movielist', []): name = data['filename'] if 'is_pc' in data and data['is_pc']: another_env_pcmovies[name] = data else: another_env_movies[name] = data def makeList(masterlist, masterdict, another_env_movies): movielist = [] for master in masterlist: data = another_env_movies.get(master.filename) is_pc = isinstance(master, PcMoviePlayList) if is_pc: thumbUrl = self.makeAppLinkUrlMedia( Media.movie_pc_thumbnail(master.filename)) else: thumbUrl = self.makeAppLinkUrlMedia( Media.movie_thumbnail(master.filename)) movielist.append({ 'id': master.id, 'name': master.name, 'filename': master.filename, 'data': getattr(master, 'data', ''), 'is_old': data and (master.edittime < data['utime']), 'thumbUrl': thumbUrl, 'is_pc': is_pc, 'stgonly': False, }) for filename in list( set(another_env_movies.keys()) - set(masterdict.keys())): data = another_env_movies.get(filename) movielist.append({ 'id': data['id'], 'name': data['name'], 'filename': filename, 'data': '', 'is_old': True, 'thumbUrl': data['thumbUrl'], 'is_pc': data.get('is_pc'), 'stgonly': True, }) return movielist movielist = makeList(masterlist, masterdict, another_env_movies) movielist.extend( makeList(pcmasterlist, pcmasterdict, another_env_pcmovies)) movielist.sort(key=lambda x: x['id']) self.html_param['downloadable'] = downloadable self.html_param['movielist'] = movielist self.html_param['uploadform'] = UploadFileForm() self.html_param['url_self'] = self.makeAppLinkUrlAdmin( UrlMaker.movie_edit()) # HTML書き出し. self.writeAppHtml('movie')