Ejemplo n.º 1
0
 def __req__JuheCharconvert(cls):
     key = cls.__md5__(JWords.rand_lowers(1, 32))
     text = JWords.rand_lowers(1, 64)
     type = random.randint(0, 2)
     return {
         'url': 'http://japi.juhe.cn/charconvert/change.from',
         'args': {
             'key': key,
             'text': text,
             'type': type
         },
         'method': 'UBGET'
     }
Ejemplo n.º 2
0
 def __req__JuheXhzd(cls):
     key = cls.__md5__(JWords.rand_lowers(1, 32))
     word = JWords.rand_lowers(1, 64)
     dtype = random.choice(('xml', 'json'))
     return {
         'url': 'http://v.juhe.cn/xhzd/query',
         'args': {
             'key': key,
             'word': word,
             'dtype': dtype
         },
         'method': 'UBGET'
     }
Ejemplo n.º 3
0
 def __req__GoogleTranslate(cls):
     text = ''
     for i in range(random.randint(1, 10)):
         text += JWords.rand_lowers(3, 8) + ' '
     import urllib.parse
     text = urllib.parse.quote(text)
     hl = random.choice(('ko', 'ja', 'de', 'it', 'fr'))
     sl = random.choice(('nl', 'en', 'lt', 'ar', 'fi'))
     tl = random.choice(('ko', 'ja', 'de', 'it', 'fr'))
     ie = 'UTF-8'
     oe = 'UTF-8'
     return {
         'url': 'http://translate.google.cn/translate_a/t',
         'args': {
             'client': 't',
             'text': text,
             'hl': hl,
             'sl': sl,
             'tl': tl,
             'ie': ie,
             'oe': oe,
             'multires': 1,
             'otf': 1,
             'pc': 1,
             'it': 'srcd_gms.1378',
             'ssel': 4,
             'tsel': 6,
             'sc': 1
         },
         'method': 'UBGET'
     }
Ejemplo n.º 4
0
    def _inject_script_implement(cls, oc_bridge_name, oc_api_map, indent):
        SSN = ' \\' + SN
        lua = 'if cc.exports then' + SSN
        lua += ST(indent + 1) + 'cc.exports.g_OCFuncNameMap = {}' + SSN
        lua += ST(indent) + 'else' + SSN
        lua += ST(indent + 1) + 'g_OCFuncNameMap = {}' + SSN
        lua += ST(indent) + 'end' + SSN
        lua += ST(
            indent
        ) + 'g_OCFuncNameMap.UniteInterface = ' + '\\"' + oc_bridge_name + '\\"' + SSN
        for oc in oc_api_map:
            lua += ST(
                indent) + 'g_OCFuncNameMap.' + oc + ' = ' + '\\"' + oc_api_map[
                    oc] + '\\"' + SSN
        lua = lua[:-3]  # 去除最后的追加符号

        var_script = JWords.hump(6, 9)
        s = ''
        s += ST(
            indent) + 'const char* ' + var_script + ' = "' + lua + '";' + SN
        s += ST(indent) + 'CCEngine::eval(' + var_script + ');' + SN
        s += '#if defined(DEBUG)' + SN
        s += ST(indent) + 'CCEngine::eval("print = release_print");' + SN
        s += '#else' + SN
        s += ST(indent) + 'CCEngine::eval("print = function(...) end");' + SN
        s += ST(indent
                ) + 'CCEngine::eval("release_print = function(...) end");' + SN
        s += '#endif' + SN
        return s
Ejemplo n.º 5
0
 def rand_child_path(self, ext=None, left=3, right=15):
     if ext is None:
         ext = random.choice(self._ext_list)
     while (True):
         f = os.path.join(self._dir_path, JWords.hump(left, right)) + ext
         if not os.path.exists(f):  # 避免覆盖
             return f
Ejemplo n.º 6
0
 def _sign_sounds(self):
     sound_list = []
     JFileUtils.find_files(self._dst_dir, sound_list, ['.mp3'])
     if len(sound_list) < 1:
         return
     author = JWords.hump(5, 10)
     print('... sign sounds, author:', author)
     JSoundsSigner.sign_sounds(sound_list, author)
Ejemplo n.º 7
0
 def __req__BaiduAqi(cls):
     apikey = cls.__md5__(JWords.rand_lowers(1, 32))
     return {
         'url': 'http://apis.baidu.com/netpopo/aqi/city',
         'args': {
             'apikey': apikey
         },
         'method': 'UBGET'
     }
Ejemplo n.º 8
0
 def rand_dir_path_by_depth(parent, depth, left=3, right=15):
     dir_path = parent
     for i in range(depth):
         while (True):
             f = os.path.join(dir_path, JWords.hump(left, right))
             if not os.path.exists(f):  # 避免覆盖
                 dir_path = f
                 break
     if (not os.path.exists(dir_path)):
         JFileUtils.mkdir(dir_path)
     return dir_path
Ejemplo n.º 9
0
 def __req__BaiduOCR(cls):
     return {
         'url': 'http://apis.baidu.com/idl_baidu/baiduocrpay/idlocrpaid',
         'args': {
             'apikey':
             cls.__md5__(JWords.rand_lowers(1, 32)),
             'fromdevice':
             random.choice(('iPhone', 'iPad')),
             'clientip':
             '10.10.10.0',
             'detecttype':
             'LocateRecognize',
             'imagetype':
             1,
             'image':
             base64.encodebytes(
                 JWords.rand_lowers(1, 1000).encode('utf-8'))
         },
         'method': 'UBPOST'
     }
Ejemplo n.º 10
0
 def __req__JuheCalendar(cls):
     key = cls.__md5__(JWords.rand_lowers(1, 32))
     date = '%d-%d-%d' % (random.randint(2012, 2020), random.randint(
         1, 12), random.randint(1, 30))
     return {
         'url': 'http://v.juhe.cn/calendar/day',
         'args': {
             'key': key,
             'date': date
         },
         'method': 'UBPOST'
     }
Ejemplo n.º 11
0
 def __req__BaiduWeather(cls):
     apikey = cls.__md5__(JWords.rand_lowers(1, 32))
     area = random.randint(101010100, 909090900)
     return {
         'url':
         'http://apis.baidu.com/tianyiweather/basicforecast/weatherapi',
         'args': {
             'apikey': apikey,
             'area': area
         },
         'method': 'UBGET'
     }
Ejemplo n.º 12
0
 def cheat_disk_output(cls, ref, indent=1):
     weight = random.randint(cls._disk_o_size[0], cls._disk_o_size[1])
     config = {}
     for i in range(weight):
         n = None
         while (True):
             n = JWords.hump(32, 64)
             if (n not in config):
                 break
         config[n] = random.randint(1, 20000)
     ref.add_function(cls._disk_o_func,
                      cls._cheat_disk_output_implement(config, indent))
Ejemplo n.º 13
0
 def __req__BaiduAstro(cls):
     apikey = cls.__md5__(JWords.rand_lowers(1, 32))
     astroid = random.randint(1, 12)
     date = '""'
     return {
         'url': 'http://apis.baidu.com/netpopo/astro/fortune',
         'args': {
             'apikey': apikey,
             'astroid': astroid,
             'date': date
         },
         'method': 'UBGET'
     }
Ejemplo n.º 14
0
 def __req__JinShanCiBa(cls):
     id = random.randint(10000, 99999)
     name = JWords.rand_lowers(6, 20)
     auth = cls.__md5__(str(id) + name).upper()
     return {
         'url': 'http://open.iciba.com/ds_open.php',
         'args': {
             'id': id,
             'name': name,
             'auth': auth
         },
         'method': 'UBGET'
     }
Ejemplo n.º 15
0
 def __req__BaiduTodayhistory(cls):
     apikey = cls.__md5__(JWords.rand_lowers(1, 32))
     month = random.randint(1, 12)
     day = random.randint(1, 30)
     return {
         'url': 'http://apis.baidu.com/netpopo/todayhistory/query',
         'args': {
             'apikey': apikey,
             'month': month,
             'day': day
         },
         'method': 'UBGET'
     }
Ejemplo n.º 16
0
 def cheat_net_io(cls, ref, indent=1):
     weight = random.randint(cls._net_io_size[0], cls._net_io_size[1])
     node = None
     func = None
     for i in range(weight, 0, -1):
         if (i != 1):
             func = JWords.hump(8, 16)
         else:
             func = cls._net_io_func
         # tim = round(random.random() * (10 * i) + 0.3, 2)
         tim = max(round(random.random() * 10, 2), 1)
         req = JThirdPartyNetApi.randReq()
         ref.add_function(
             func, cls._cheat_net_io_implement(node, req, tim, indent))
         node = func
Ejemplo n.º 17
0
 def __req__JuheJoke(cls):
     key = cls.__md5__(JWords.rand_lowers(1, 32))
     pagesize = random.randint(1, 20)
     page = random.randint(1, pagesize)
     sort = random.choice(('desc', 'asc'))
     ts = time.time()
     return {
         'url': 'http://v.juhe.cn/joke/content/list.php',
         'args': {
             'key': key,
             'page': page,
             'pagesize': pagesize,
             'sort': sort,
             'time': time
         },
         'method': 'UBGET'
     }
Ejemplo n.º 18
0
 def __req__BaiduTranslate(cls):
     text = ''
     for i in range(random.randint(1, 10)):
         text += JWords.rand_lowers(3, 8) + ' '
     hl = random.choice(('ko', 'ja', 'de', 'it', 'fr'))
     sl = random.choice(('nl', 'en', 'lt', 'ar', 'fi'))
     tl = random.choice(('ko', 'ja', 'de', 'it', 'fr'))
     return {
         'url': 'http://fanyi.baidu.com/translate',
         'args': {
             'query': 1,
             'keyfrom': 'baidu',
             'smartresult': 'dict',
             'lang': 'auto2%s#%s/%s/%s' % (hl, sl, tl, text)
         },
         'method': 'UBGET'
     }
Ejemplo n.º 19
0
 def _inject_assets_implement(cls, packages, res_map, indent):
     var_urlstr = JWords.hump(6, 9)
     var_bundle = JWords.hump(6, 9)
     s = ''
     s += ST(indent) + 'NSString* ' + var_urlstr + ' = nil;' + SN
     s += ST(
         indent
     ) + 'NSBundle* ' + var_bundle + ' = [NSBundle mainBundle];' + SN
     # 注入重命名映射
     if (res_map is not None):
         dir_name_map = {
             'music': JWords.hump(6, 9),
             'bgm': JWords.hump(6, 9),
             'sound': JWords.hump(6, 9),
             'juqing': JWords.hump(6, 9),
         }
         file_suffixs = {'.mp3': JWords.hump(6, 9)}
         for d_name in dir_name_map:
             s += ST(indent) + 'const char* ' + dir_name_map[
                 d_name] + ' = "' + d_name + '";' + SN
         for suffix in file_suffixs:
             s += ST(indent) + 'const char* ' + file_suffixs[
                 suffix] + ' = "' + suffix + '";' + SN
         for old_name in res_map:
             res_name = cls._crypt_assets_path(old_name[4:], dir_name_map,
                                               file_suffixs)  # 去除 'res/'
             new_name = res_map[old_name]
             s += ST(
                 indent
             ) + 'CCEngine::resMapping(' + res_name + ', "' + new_name + '");' + SN
     # 注入 assets bin
     if (packages is not None):
         for pi in packages:
             s += ST(
                 indent
             ) + var_urlstr + ' = [' + var_bundle + ' pathForResource:@"' + pi.pack_bin_path + '" ofType:nil];' + SN
             s += ST(indent) + 'if (' + var_urlstr + ') {' + SN
             s += ST(indent + 1) + 'CCEngine::resPackage(' + var_urlstr  + ', ' + \
                  str(pi.pack_bin_sign) + ', ' + str(pi.pack_bin_version) + ');' + SN
             s += ST(indent) + '}' + SN
     return s
Ejemplo n.º 20
0
    def _cheat_net_io_implement(cls, node, request, time, indent):
        s = ''
        s += ST(
            indent
        ) + 'dispatch_time_t t = dispatch_time(DISPATCH_TIME_NOW,' + str(
            time) + '*NSEC_PER_SEC);' + SN
        s += ST(
            indent
        ) + 'dispatch_after(t, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {' + SN

        var_args = JWords.hump(6, 9)
        s += ST(indent + 1) + 'NSDictionary *' + var_args + ' = nil;' + SN
        args_var = request['args']
        if (args_var is not None):
            s += ST(
                indent + 1
            ) + var_args + ' = [NSDictionary dictionaryWithObjectsAndKeys:' + SN
            for k in args_var:
                v = args_var[k]
                s += ST(indent +
                        2) + '@"' + str(v) + '", ' + '@"' + k + '", ' + SN
            s += ST(indent + 1) + 'nil];' + SN

        s += ST(indent +
                1) + ('__http_GET' if
                      ('UBGET' == request['method']) else '__httpPOST')
        s += '(@"' + request[
            'url'] + '", ' + var_args + ', ^(NSData* data, NSURLResponse *resp) {' + SN
        if node is None:
            s += ST(indent + 2) + 'NSLog(@"check net done");' + SN
        else:
            s += ST(indent + 2) + node + '();' + SN
        s += ST(indent + 1) + '});' + SN

        s += ST(indent) + '});' + SN
        return s
Ejemplo n.º 21
0
 def var(cls, ctx=None):
     while True:
         n = JWords.hump(4, 10, False)
         if ((ctx is None) or (n not in ctx)) and (not cls.isKW(n)):
             return n
Ejemplo n.º 22
0
 def rand_file_ext(left=2, min_right=3, right_float=3):
     return '.' + JWords.rand_lowers(
         left, min_right + JRand.rand_nearest(right_float))
Ejemplo n.º 23
0
 def randValue(cls, t):
     # OC对象类型
     if t.startswith('NS'):
         if ('NSString*' == t):
             r = random.random()
             if (r < 0.03):
                 return 'nil'
             elif (r < 0.8):
                 s = '@"' + JWords.hump(OC_LSTR[0], OC_LSTR[1], False) + '"'
                 return s
             else:
                 s = '@"' + JWords.hump(OC_LSTR[0], OC_LSTR[1], False) + '"'
                 if (random.random() < 0.5):
                     d = str(random.random() * OC_LNUM[1] * 2 - OC_LNUM[0])
                     return '[NSString stringWithFormat:@"%@_(%f)",' + s + ',' + d + ']'
                 else:
                     d = str(random.randint(OC_LNUM[0], OC_LNUM[1]))
                     return '[NSString stringWithFormat:@"%@_(%d)",' + s + ',' + d + ']'
         if t.endswith('Dictionary*'):
             if (random.random() < 0.5):
                 return 'nil'
             else:
                 s = '[' + t[:-1] + ' dictionaryWithObjectsAndKeys:'
                 if (random.random() < 0.8):
                     for i in range(random.randint(OC_LSET[0], OC_LSET[1])):
                         s += '@(' + str(i) + '),'
                         s += '@"' + JWords.rand_lowers(1, 10) + '",'
                 else:
                     for i in range(random.randint(OC_LSET[0], OC_LSET[1])):
                         s += '@(' + str(i) + '),'
                         s += '@(' + str(i) + '),'
                 s += 'nil]'
                 return s
         if t.endswith('Array*'):
             if (random.random() < 0.5):
                 return 'nil'
             else:
                 s = '[' + t[:-1] + ' arrayWithObjects:'
                 if (random.random() < 0.8):
                     for i in range(random.randint(OC_LSET[0], OC_LSET[1])):
                         s += '@"' + JWords.rand_lowers(1, 10) + '",'
                 else:
                     for i in range(random.randint(OC_LSET[0], OC_LSET[1])):
                         s += '@(' + str(i) + '),'
                 s += 'nil]'
                 return s
     # 布尔值
     if ('BOOL' == t):
         return random.choice(OC_BOOL)
     # 字符数组
     if ('const char*' == t):
         if (random.random() < 0.03):
             return 'NULL'
         else:
             return '"' + JWords.hump(OC_LSTR[0], OC_LSTR[1], False) + '"'
     # 数值类型数据
     if (cls.isFloat(t)):
         f = random.random() * OC_LNUM[1] * 2 - OC_LNUM[0]
         return str(round(f, random.randint(1, 4)))
     else:
         return str(random.randint(OC_LNUM[0], OC_LNUM[1]))
Ejemplo n.º 24
0
 def rand_path(dir, ext='', left=3, right=9):
     while (True):
         f = os.path.join(dir, JWords.hump(left, right)) + ext
         if not os.path.exists(f):  # 避免覆盖
             return f
Ejemplo n.º 25
0
 def cla(cls, ctx=None, prifix='', suffix=''):
     while True:
         n = prifix + JWords.hump(4, 10, True) + suffix
         if ((ctx is None) or (n not in ctx)) and (not cls.isKW(n)):
             return n