FPC 0.76__tar.gz → 0.78__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fpc-0.76 → fpc-0.78}/FPC/__init__.py +50 -15
- {fpc-0.76 → fpc-0.78}/FPC.egg-info/PKG-INFO +1 -1
- {fpc-0.76 → fpc-0.78}/PKG-INFO +1 -1
- {fpc-0.76 → fpc-0.78}/setup.py +1 -1
- {fpc-0.76 → fpc-0.78}/FPC.egg-info/SOURCES.txt +0 -0
- {fpc-0.76 → fpc-0.78}/FPC.egg-info/dependency_links.txt +0 -0
- {fpc-0.76 → fpc-0.78}/FPC.egg-info/top_level.txt +0 -0
- {fpc-0.76 → fpc-0.78}/LICENSE +0 -0
- {fpc-0.76 → fpc-0.78}/README.md +0 -0
- {fpc-0.76 → fpc-0.78}/setup.cfg +0 -0
|
@@ -13,7 +13,7 @@ def now(x=None):#x='micro' return microsecond;x='str' return now time to string;
|
|
|
13
13
|
if not x:return int(datetime.datetime.now().timestamp())
|
|
14
14
|
elif x=='micro':return datetime.datetime.now().timestamp()
|
|
15
15
|
elif x=='str':return datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
|
16
|
-
elif isinstance(x,(int,float)):return datetime.datetime.fromtimestamp(x).strftime('%Y-%m-%d %H:%M:%S')
|
|
16
|
+
elif isinstance(x,(int,float)):return datetime.datetime.fromtimestamp(x if x <1e11 else x/1000).strftime('%Y-%m-%d %H:%M:%S')
|
|
17
17
|
else:
|
|
18
18
|
try: import dateutil.parser;return int(dateutil.parser.parse(x).timestamp())
|
|
19
19
|
except Exception: return int(datetime.datetime.strptime(x, '%Y-%m-%d %H:%M:%S').timestamp())
|
|
@@ -54,11 +54,12 @@ def print(*a,func=None,time='%m/%d %H:%M:%S',pretty=False,**s):
|
|
|
54
54
|
for i,x in enumerate(a):
|
|
55
55
|
a[i]=func(x)
|
|
56
56
|
if time:
|
|
57
|
-
|
|
57
|
+
builtins.print(datetime.datetime.now().strftime(time)+' : ',end='',**s)
|
|
58
58
|
if pretty:
|
|
59
59
|
import pprint
|
|
60
|
+
if s.get('file'):s['stream']=s.pop('file')
|
|
60
61
|
for x in a:
|
|
61
|
-
pprint.pprint(x)
|
|
62
|
+
pprint.pprint(x,**s)
|
|
62
63
|
else:
|
|
63
64
|
builtins.print(*a,**s)
|
|
64
65
|
def split_str(strs,num=1):
|
|
@@ -71,25 +72,30 @@ def diff(a,b):
|
|
|
71
72
|
for x in a:
|
|
72
73
|
if b.get(x)!=a[x]: diff[x]=[a[x],b.get(x)]
|
|
73
74
|
return diff
|
|
74
|
-
def notice(x,c='default',silent=None,channel=None):
|
|
75
|
+
def notice(x,c='default',silent=None,channel=None,is_async=False,_time=''):
|
|
76
|
+
if is_async:
|
|
77
|
+
process(notice,args=(x,c,silent,channel,False,_time))
|
|
78
|
+
return True
|
|
75
79
|
if silent:
|
|
76
80
|
red=redis()
|
|
77
81
|
if red.exists(x if not channel else channel):return
|
|
78
82
|
else:
|
|
79
83
|
red.set(x if not channel else channel,'1',silent)
|
|
80
|
-
try:
|
|
81
|
-
|
|
84
|
+
try:
|
|
85
|
+
request.urlopen(f'http://call.ff2.pw/?{c}={urllib.parse.quote_plus(x)}&passwd=frank&time={urllib.parse.quote_plus(_time)}')
|
|
86
|
+
return True
|
|
87
|
+
except:return False
|
|
82
88
|
def rand_sleep(i=0.4,a=0.8):import random;time.sleep(random.randint(int(i*1000),int(a*1000))/1000);
|
|
83
89
|
def rand(i=9,a=None):import random;return random.randint(int(i),int(a)) if a else random.randint(0,int(i-1));
|
|
84
90
|
def md5(x):hl = hashlib.md5();hl.update(x.encode('utf-8') if isinstance(x,str) else x);return hl.hexdigest();
|
|
85
91
|
def bin2hex(x):import binascii;return binascii.hexlify(x.encode('utf-8') if isinstance(x,str) else x);
|
|
86
92
|
def base64_encode(x):import base64;return base64.b64encode(x) if isinstance(x,bytes) else base64.b64encode(x.encode('utf-8'))
|
|
87
93
|
def base64_decode(x):import base64;return base64.b64decode(x+(b'===' if isinstance(x,bytes) else '==='))
|
|
88
|
-
def log(*x,path=None):#已经带有时间
|
|
94
|
+
def log(*x,path=None,**s):#已经带有时间
|
|
89
95
|
if path is None:
|
|
90
|
-
path='/tmp/
|
|
96
|
+
path='/tmp/FPC.log' if os.path.exists('/tmp') else './FPC.log'
|
|
91
97
|
with open(path,'a',encoding='utf-8') as f:
|
|
92
|
-
print(*x,file=f)
|
|
98
|
+
print(*x,file=f,**s)
|
|
93
99
|
def parse(o):#print class/obj's attr beatiful
|
|
94
100
|
method=[];attr=[]
|
|
95
101
|
for x in dir(o):
|
|
@@ -336,21 +342,50 @@ def process_arg_construct(urls:list,args):#args must be iterable
|
|
|
336
342
|
for i,url in enumerate(urls):
|
|
337
343
|
proc_args.append((url,args[i*every_proc_count:i*every_proc_count+every_proc_count]))
|
|
338
344
|
return proc_args
|
|
339
|
-
def process(target,is_thread=True,join=False,num=1,sleep=None,daemon=False,**args):
|
|
345
|
+
def process(target,is_thread=True,join=False,num:int=1,sleep=None,daemon=False,**args):
|
|
346
|
+
'''args:{
|
|
347
|
+
'sync':True,
|
|
348
|
+
'args':[('',),('',)]for mult proc,('','')for single proc the same parameter to multiple processes specified by num,
|
|
349
|
+
'kwargs':[{'':''}]for mult proc,{'':''}like args,
|
|
350
|
+
} or others that transfer to Thread or Process'''
|
|
340
351
|
if isinstance(target,(str,list)):#args:target,[sync=True]
|
|
341
352
|
import subprocess
|
|
342
353
|
proc=subprocess.Popen(target,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True if isinstance(target,str) else False);
|
|
343
354
|
return proc.communicate() if args.get('sync',True) else proc
|
|
344
355
|
pros=[]
|
|
345
|
-
if 'args' in args
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
356
|
+
if 'args' in args and 'kwargs' in args and 'kwargs' in args:
|
|
357
|
+
_num=max(len(args['args'])if isinstance(args['args'],list)else 0,len(args['kwargs'])if isinstance(args['kwargs'],list)else 0)
|
|
358
|
+
if num!=1 and num!=_num:
|
|
359
|
+
raise ValueError(f'max args length is {_num} not equal to num:{num}')
|
|
360
|
+
num=_num
|
|
361
|
+
if 'args' in args:
|
|
362
|
+
if isinstance(args['args'],tuple):
|
|
363
|
+
args_list=[args['args']]*num
|
|
364
|
+
elif isinstance(args['args'],list):
|
|
365
|
+
if num!=1 and num!=len(args['args']):
|
|
366
|
+
raise ValueError('args length must be equal to num')
|
|
367
|
+
args_list=args['args']
|
|
368
|
+
num=len(args_list)
|
|
369
|
+
else:
|
|
370
|
+
raise ValueError('args must be tuple or list')
|
|
371
|
+
if 'kwargs' in args:
|
|
372
|
+
if isinstance(args['kwargs'],dict):
|
|
373
|
+
kwargs_list=[args['kwargs']]*num
|
|
374
|
+
elif isinstance(args['kwargs'],list):
|
|
375
|
+
if num!=1 and num!=len(args['kwargs']):
|
|
376
|
+
raise ValueError('kwargs length must be equal to num')
|
|
377
|
+
kwargs_list=args['kwargs']
|
|
378
|
+
num=len(kwargs_list)
|
|
379
|
+
else:
|
|
380
|
+
raise ValueError('kwargs must be tuple or list')
|
|
381
|
+
|
|
349
382
|
if is_thread: from threading import Thread as proc
|
|
350
383
|
else: from multiprocessing import Process as proc
|
|
351
384
|
for x in range(num):
|
|
352
385
|
if 'args' in args:
|
|
353
|
-
args['args']=args_list[x]
|
|
386
|
+
args['args']=args_list[x]
|
|
387
|
+
if 'kwargs' in args:
|
|
388
|
+
args['kwargs']=kwargs_list[x]
|
|
354
389
|
pros.append(proc(target=target,**args))
|
|
355
390
|
if daemon : pros[-1].daemon=True
|
|
356
391
|
pros[-1].start()
|
{fpc-0.76 → fpc-0.78}/PKG-INFO
RENAMED
{fpc-0.76 → fpc-0.78}/setup.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fpc-0.76 → fpc-0.78}/LICENSE
RENAMED
|
File without changes
|
{fpc-0.76 → fpc-0.78}/README.md
RENAMED
|
File without changes
|
{fpc-0.76 → fpc-0.78}/setup.cfg
RENAMED
|
File without changes
|