kmisc 2.1.86__py3-none-any.whl → 2.1.88__py3-none-any.whl
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.
- kmisc/__init__.py +98 -141
- {kmisc-2.1.86.dist-info → kmisc-2.1.88.dist-info}/METADATA +1 -1
- kmisc-2.1.88.dist-info/RECORD +6 -0
- kmisc-2.1.86.dist-info/RECORD +0 -6
- {kmisc-2.1.86.dist-info → kmisc-2.1.88.dist-info}/LICENSE +0 -0
- {kmisc-2.1.86.dist-info → kmisc-2.1.88.dist-info}/WHEEL +0 -0
- {kmisc-2.1.86.dist-info → kmisc-2.1.88.dist-info}/top_level.txt +0 -0
kmisc/__init__.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/bin/python
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
# Kage personal stuff
|
4
|
-
#
|
5
4
|
from __future__ import print_function
|
6
5
|
import os
|
7
6
|
import re
|
@@ -13,55 +12,60 @@ import time
|
|
13
12
|
import uuid
|
14
13
|
import zlib
|
15
14
|
import copy
|
16
|
-
import
|
17
|
-
import tarfile
|
18
|
-
import zipfile
|
15
|
+
import json
|
19
16
|
import random
|
20
|
-
import struct
|
21
17
|
import string
|
22
|
-
import fnmatch
|
23
|
-
import pickle
|
24
|
-
import tarfile
|
25
|
-
import zipfile
|
26
18
|
import pickle
|
27
19
|
import random
|
28
|
-
import inspect
|
29
20
|
import base64
|
30
21
|
import hashlib
|
22
|
+
import fnmatch
|
23
|
+
import smtplib
|
24
|
+
import tarfile
|
25
|
+
import zipfile
|
26
|
+
import tarfile
|
27
|
+
import zipfile
|
28
|
+
import inspect
|
29
|
+
import traceback
|
31
30
|
import importlib
|
32
31
|
import subprocess
|
33
|
-
import traceback
|
34
|
-
import fcntl,socket,struct
|
35
|
-
import json
|
36
32
|
import email.utils
|
37
|
-
import xml.etree.ElementTree as ET
|
38
33
|
from sys import modules
|
39
|
-
from sys import path as mod_path
|
40
|
-
from sys import version_info
|
41
34
|
from pprint import pprint
|
35
|
+
import fcntl,socket,struct
|
36
|
+
from email import encoders
|
37
|
+
from sys import version_info
|
42
38
|
from threading import Thread
|
43
39
|
from datetime import datetime
|
44
|
-
from
|
40
|
+
from http.cookies import Morsel # This module for requests when you use build by pyinstaller command
|
41
|
+
from sys import path as mod_path
|
42
|
+
import xml.etree.ElementTree as ET
|
45
43
|
from email.mime.text import MIMEText
|
46
44
|
from email.mime.base import MIMEBase
|
47
|
-
from email.mime.multipart import MIMEMultipart
|
48
|
-
from multiprocessing import Process, Queue
|
49
45
|
from distutils.version import LooseVersion
|
50
|
-
from
|
51
|
-
|
46
|
+
from multiprocessing import Process, Queue
|
47
|
+
from email.mime.multipart import MIMEMultipart
|
48
|
+
try:
|
49
|
+
from kmport import *
|
50
|
+
except:
|
51
|
+
pip_user_install='--user' if os.environ.get('VIRTUAL_ENV') is None else ''
|
52
|
+
os.system('''for i in 1 2 3 4 5; do python3 -m pip install pip --upgrade {} 2>&1 | grep "however version" |grep "is available" >& /dev/null || break; done'''.format(pip_user_install))
|
53
|
+
os.system('python3 -m pip install kmport {}'.format(pip_user_install))
|
54
|
+
try:
|
55
|
+
from kmport import *
|
56
|
+
except:
|
57
|
+
print('Can not install kmport')
|
58
|
+
os._exit(1)
|
52
59
|
|
53
|
-
from http.cookies import Morsel # This module for requests when you use build by pyinstaller command
|
54
60
|
|
61
|
+
global krc_define
|
55
62
|
global printf_log_base
|
56
|
-
global printf_caller_detail
|
57
63
|
global printf_caller_tree
|
58
|
-
global
|
59
|
-
url_group = re.compile('^(https|http|ftp)://([^/\r\n]+)(/[^\r\n]*)?')
|
60
|
-
#log_file=None
|
64
|
+
global printf_caller_detail
|
61
65
|
log_intro=3
|
62
|
-
log_new_line='\n'
|
63
66
|
pipe_file=None
|
64
|
-
|
67
|
+
log_new_line='\n'
|
68
|
+
url_group = re.compile('^(https|http|ftp)://([^/\r\n]+)(/[^\r\n]*)?')
|
65
69
|
cdrom_ko=['sr_mod','cdrom','libata','ata_piix','ata_generic','usb-storage']
|
66
70
|
|
67
71
|
def Abs(*inps,**opts):
|
@@ -762,8 +766,8 @@ class IP:
|
|
762
766
|
log=opts.get('log',None)
|
763
767
|
init_time=None
|
764
768
|
if self.IsV4(ip):
|
765
|
-
if not
|
766
|
-
if not
|
769
|
+
if not ping(ip,count=5):
|
770
|
+
if not ping(ip,count=0,timeout=timeout_sec,keep_good=keep_good,interval=interval,cancel_func=cancel_func,log=log):
|
767
771
|
return True
|
768
772
|
return False
|
769
773
|
return default
|
@@ -815,7 +819,7 @@ class IP:
|
|
815
819
|
def Ping(self,host='_#_',count=0,interval=1,keep_good=0, timeout=0,lost_mon=False,log=None,stop_func=None,log_format='.',cancel_func=None):
|
816
820
|
#if IsNone(host,chk_val=['_#_'],chk_only=True): host=self.ip
|
817
821
|
host=self.GetIP(host)
|
818
|
-
return
|
822
|
+
return ping(host,count=count,interval=interval,keep_good=keep_good,timeout=timeout,lost_mon=lost_mon,log=log,stop_func=stop_func,log_format=log_format,cancel_func=cancel_func)
|
819
823
|
|
820
824
|
def IsJson(src):
|
821
825
|
try:
|
@@ -2400,56 +2404,6 @@ def Update(src,*inps,**opts):
|
|
2400
2404
|
src.update(opts)
|
2401
2405
|
return src
|
2402
2406
|
|
2403
|
-
def Random(length=8,strs=None,mode='*',letter='*',default=1):
|
2404
|
-
if mode in [int,'int','num','number']:
|
2405
|
-
if isinstance(strs,(list,tuple)) and len(strs) == 2:
|
2406
|
-
try:
|
2407
|
-
s=int(strs[0])
|
2408
|
-
n=int(strs[1])
|
2409
|
-
return random.randint(s,n)
|
2410
|
-
except:
|
2411
|
-
pass
|
2412
|
-
s=0
|
2413
|
-
n=''
|
2414
|
-
for i in range(0,length):
|
2415
|
-
n=n+'9'
|
2416
|
-
if n:
|
2417
|
-
return random.randint(s,int(n))
|
2418
|
-
return default
|
2419
|
-
new=''
|
2420
|
-
# if mode in [int,'int','num']:
|
2421
|
-
# for i in range(0,length):
|
2422
|
-
# new='{0}{1}'.format(new,random.randint(0,9))
|
2423
|
-
# return int(num)
|
2424
|
-
if not isinstance(strs,str) or not strs:
|
2425
|
-
strs=''
|
2426
|
-
if 'alpha' in mode or mode in ['all','*']:
|
2427
|
-
if letter == 'upper':
|
2428
|
-
strs=string.ascii_uppercase
|
2429
|
-
elif letter == 'lower':
|
2430
|
-
strs=string.ascii_lowercase
|
2431
|
-
elif letter in ['*','all']:
|
2432
|
-
strs=string.ascii_letters
|
2433
|
-
if 'num' in mode or mode in ['all','*']:
|
2434
|
-
strs=strs+string.digits
|
2435
|
-
if 'char' in mode or 'sym' in mode or mode in ['all','*']:
|
2436
|
-
strs=strs+string.punctuation
|
2437
|
-
# if mode in ['all','*','alphanumchar']:
|
2438
|
-
# strs='0aA-1b+2Bc=C3d_D,4.eE?5"fF6g7G!h8H@i9#Ij$JkK%lLmMn^N&oO*p(Pq)Q/r\Rs:St;TuUv{V<wW}x[Xy>Y]z|Z'
|
2439
|
-
# elif mode in ['alphachar']:
|
2440
|
-
# strs='aA-b+Bc=Cd_D,.eE?"fFgG!hH@i#Ij$JkK%lLmMn^N&oO*p(Pq)Q/r\Rs:St;TuUv{V<wW}x[Xy>Y]z|Z'
|
2441
|
-
# elif mode in ['alphanum']:
|
2442
|
-
# strs='aA1b2BcC3dD4eE5fF6g7Gh8Hi9IjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'
|
2443
|
-
# elif mode in ['char']:
|
2444
|
-
# strs='-+=_,.?"!@#$%^&*()/\:;{<}x[>]|'
|
2445
|
-
# else:
|
2446
|
-
# strs='aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'
|
2447
|
-
if not strs: strs=string.ascii_letters
|
2448
|
-
strn=len(strs)-1
|
2449
|
-
for i in range(0,length):
|
2450
|
-
new='{0}{1}'.format(new,strs[random.randint(0,strn)])
|
2451
|
-
return new
|
2452
|
-
|
2453
2407
|
def Keys(src,find=None,start=None,end=None,sym='\n',default=[],word=False,pattern=False,findall=False,out=None):
|
2454
2408
|
rt=[]
|
2455
2409
|
if isinstance(src,str,list,tuple) and find:
|
@@ -3016,7 +2970,7 @@ def find_usb_dev(size=None,max_size=None):
|
|
3016
2970
|
#Payload Channel : 1 (0x01)
|
3017
2971
|
#Payload Port : 623
|
3018
2972
|
|
3019
|
-
def net_send_data(sock,data,key='kg',enc=False,timeout=0,close=False):
|
2973
|
+
def net_send_data(sock,data,key='kg',enc=False,timeout=0,close=False,instant=True,log=None):
|
3020
2974
|
# if close=True then just send data and close socket
|
3021
2975
|
# if close=False then it need close socket code
|
3022
2976
|
# ex)
|
@@ -3040,10 +2994,11 @@ def net_send_data(sock,data,key='kg',enc=False,timeout=0,close=False):
|
|
3040
2994
|
ndata=struct.pack('>IssI',len(pdata),data_type,enc_tf,nkey)+pdata
|
3041
2995
|
try:
|
3042
2996
|
sock.sendall(ndata)
|
3043
|
-
if close:
|
2997
|
+
if close and instant is not False:
|
2998
|
+
sock.close()
|
3044
2999
|
return True,'OK'
|
3045
3000
|
except:
|
3046
|
-
if close:
|
3001
|
+
if close and instant is not False:
|
3047
3002
|
if sock: sock.close()
|
3048
3003
|
if timeout > 0:
|
3049
3004
|
#timeout=sock.gettimeout()
|
@@ -3052,9 +3007,9 @@ def net_send_data(sock,data,key='kg',enc=False,timeout=0,close=False):
|
|
3052
3007
|
return False,'Sending Socket Timeout'
|
3053
3008
|
return False,'Sending Fail'
|
3054
3009
|
|
3055
|
-
def net_receive_data(sock,key='kg',progress=None,retry=0,retry_timeout=30,progress_msg=None):
|
3010
|
+
def net_receive_data(sock,key='kg',progress=None,retry=0,retry_timeout=30,progress_msg=None,log=None):
|
3056
3011
|
# decode code here
|
3057
|
-
def recvall(sock,count,progress=False,progress_msg=None): # Packet
|
3012
|
+
def recvall(sock,count,progress=False,progress_msg=None,log=None): # Packet
|
3058
3013
|
buf = b''
|
3059
3014
|
file_size_d=int('{0}'.format(count))
|
3060
3015
|
#if progress: print('\n')
|
@@ -3063,14 +3018,14 @@ def net_receive_data(sock,key='kg',progress=None,retry=0,retry_timeout=30,progre
|
|
3063
3018
|
while count:
|
3064
3019
|
if progress:
|
3065
3020
|
if progress_msg:
|
3066
|
-
|
3021
|
+
printf('\r{} [ {} % ]'.format(progress_msg,int((file_size_d-count) / file_size_d * 100)),log=log)
|
3067
3022
|
else:
|
3068
|
-
|
3023
|
+
printf('\rDownloading... [ {} % ]'.format(int((file_size_d-count) / file_size_d * 100)),log=log,dsp='e')
|
3069
3024
|
try:
|
3070
3025
|
newbuf = sock.recv(count)
|
3071
3026
|
except socket.error as e:
|
3072
3027
|
if tn < retry:
|
3073
|
-
|
3028
|
+
printf("[ERROR] timeout value:{} retry: {}/{}\n{}".format(sock.gettimeout(),tn,retry,e),log=log,dsp='e')
|
3074
3029
|
tn+=1
|
3075
3030
|
TIME().Sleep(1)
|
3076
3031
|
sock.settimeout(retry_timeout)
|
@@ -3082,9 +3037,9 @@ def net_receive_data(sock,key='kg',progress=None,retry=0,retry_timeout=30,progre
|
|
3082
3037
|
count -= len(newbuf)
|
3083
3038
|
if progress:
|
3084
3039
|
if progress_msg:
|
3085
|
-
|
3040
|
+
printf('\r{} [ 100 % ]\n'.format(progress_msg),log=log)
|
3086
3041
|
else:
|
3087
|
-
|
3042
|
+
printf('\rDownloading... [ 100 % ]\n',log=log,dsp='e')
|
3088
3043
|
return True,buf
|
3089
3044
|
ok,head=recvall(sock,10)
|
3090
3045
|
if krc(ok,chk=True):
|
@@ -3093,70 +3048,73 @@ def net_receive_data(sock,key='kg',progress=None,retry=0,retry_timeout=30,progre
|
|
3093
3048
|
#st_head=struct.unpack('>IssI',Bytes(head))
|
3094
3049
|
st_head=struct.unpack('>IssI',Bytes(head))
|
3095
3050
|
except:
|
3096
|
-
return
|
3051
|
+
return False,'Fail for read header({})'.format(head)
|
3097
3052
|
if st_head[3] == Bytes2Int(key,encode='utf-8',default='org'):
|
3098
3053
|
# File not found Error log size is 57. So if 57 then ignore progress
|
3099
3054
|
if st_head[0] == 57: progress=False
|
3100
|
-
ok,data=recvall(sock,st_head[0],progress=progress,progress_msg=progress_msg)
|
3055
|
+
ok,data=recvall(sock,st_head[0],progress=progress,progress_msg=progress_msg,log=log)
|
3101
3056
|
if krc(ok,chk=True):
|
3102
3057
|
if st_head[2] == 't':
|
3103
3058
|
# decode code here
|
3104
3059
|
# data=decode(data)
|
3105
3060
|
pass
|
3106
|
-
if data: return
|
3107
|
-
return
|
3061
|
+
if data: return st_head[1],pickle.loads(data)
|
3062
|
+
return True,None
|
3108
3063
|
else:
|
3109
|
-
return
|
3064
|
+
return ok,data
|
3110
3065
|
else:
|
3111
|
-
return
|
3112
|
-
return
|
3113
|
-
return
|
3066
|
+
return False,'Wrong key'
|
3067
|
+
return 'lost','Connection lost'
|
3068
|
+
return ok,head
|
3114
3069
|
|
3115
|
-
def net_put_and_get_data(IP,data,PORT=8805,key='kg',timeout=3,try_num=1,try_wait=[0,5],progress=None,enc=False,upacket=None,SSLC=False,
|
3070
|
+
def net_put_and_get_data(IP,data,PORT=8805,key='kg',timeout=3,try_num=1,try_wait=[0,5],progress=None,enc=False,upacket=None,SSLC=False,progress_msg=None,instant=True,log=None):
|
3116
3071
|
sent=False,'Unknown issue'
|
3117
3072
|
for ii in range(0,try_num):
|
3118
3073
|
if upacket: # Update packet function for number of try information ([#/<total #>])
|
3119
3074
|
data=upacket('ntry',[ii+1,try_num],data)
|
3120
3075
|
start_time=TIME().Int()
|
3121
|
-
sock=net_get_socket(IP,PORT,timeout=timeout,SSLC=SSLC)
|
3076
|
+
ok,sock=net_get_socket(IP,PORT,timeout=timeout,SSLC=SSLC,log=log)
|
3122
3077
|
if try_num > 0:
|
3123
3078
|
rtry_wait=(timeout//try_num)+1
|
3124
3079
|
else:
|
3125
3080
|
rtry_wait=try_wait
|
3126
|
-
sent=False,'Unknown issue'
|
3081
|
+
sent=False,'Unknown issue',sock
|
3127
3082
|
try:
|
3128
|
-
sent=net_send_data(sock,data,key=key,enc=enc)
|
3083
|
+
sent=net_send_data(sock,data,key=key,enc=enc,log=log)
|
3129
3084
|
except:
|
3130
3085
|
os.system("""[ -f /tmp/.{0}.{1}.crt ] && rm -f /tmp/.{0}.{1}.crt""".format(IP,PORT))
|
3131
3086
|
if sent[0]:
|
3132
|
-
nrcd=net_receive_data(sock,key=key,progress=progress,progress_msg=progress_msg)
|
3133
|
-
return nrcd
|
3087
|
+
nrcd=net_receive_data(sock,key=key,progress=progress,progress_msg=progress_msg,log=log)
|
3088
|
+
return nrcd,'done',sock
|
3134
3089
|
else:
|
3135
3090
|
if timeout >0:
|
3136
3091
|
if TIME().Int() - start_time >= timeout-1:
|
3137
|
-
return
|
3092
|
+
return False,'Socket Send Timeout',sock
|
3138
3093
|
#return [False,'Data protocol version mismatch']
|
3139
|
-
if sock:
|
3094
|
+
if sock and instant is True:
|
3095
|
+
sock.close()
|
3096
|
+
sock=None
|
3140
3097
|
if try_num > 1:
|
3141
|
-
|
3142
|
-
print('try send data ... [{}/{}]'.format(ii+1,try_num))
|
3098
|
+
printf('try send data ... [{}/{}]'.format(ii+1,try_num),log=log)
|
3143
3099
|
TIME().Sleep(try_wait)
|
3144
|
-
return
|
3100
|
+
return False,'Send fail({}) :\n{}'.format(sent[1],data),sock
|
3145
3101
|
|
3146
|
-
def net_get_socket(host,port,timeout=3,dbg=
|
3102
|
+
def net_get_socket(host,port,timeout=3,dbg=6,SSLC=False,log=None): # host : Host name or IP
|
3147
3103
|
try:
|
3148
3104
|
af, socktype, proto, canonname, sa = socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM)[0]
|
3149
3105
|
except:
|
3150
|
-
|
3151
|
-
return False
|
3106
|
+
_e_='Can not get network informatin of {}:{}'.format(host,port)
|
3107
|
+
return False,_e_
|
3152
3108
|
try:
|
3153
3109
|
soc = socket.socket(af, socktype, proto)
|
3154
3110
|
if timeout > 0:
|
3155
3111
|
soc.settimeout(timeout)
|
3156
3112
|
except socket.error as msg:
|
3157
|
-
|
3158
|
-
|
3113
|
+
_e_='could not open socket of {0}:{1}\n{2}'.format(host,port,msg)
|
3114
|
+
printf(_e_,log=log,dsp='e')
|
3115
|
+
return False,_e_
|
3159
3116
|
###### SSL Wrap ######
|
3117
|
+
_e_=None
|
3160
3118
|
if SSLC:
|
3161
3119
|
for i in range(0,5):
|
3162
3120
|
icertfile='/tmp/.{}.{}.crt'.format(host,port)
|
@@ -3173,22 +3131,21 @@ def net_get_socket(host,port,timeout=3,dbg=0,SSLC=False): # host : Host name or
|
|
3173
3131
|
try:
|
3174
3132
|
soc=ssl.wrap_socket(soc,ca_certs=icertfile,cert_reqs=ssl.CERT_REQUIRED)
|
3175
3133
|
soc.connect((host,port))
|
3176
|
-
return soc
|
3134
|
+
return soc,'ok'
|
3177
3135
|
except socket.error as msg:
|
3178
|
-
|
3179
|
-
print(msg)
|
3136
|
+
printf(msg,log=log,log_level=dbg,mode='e')
|
3180
3137
|
TIME().Sleep(1)
|
3181
3138
|
########################
|
3182
3139
|
else:
|
3183
3140
|
try:
|
3184
3141
|
soc.connect(sa)
|
3185
|
-
return soc
|
3142
|
+
return soc,'ok'
|
3186
3143
|
except socket.error as msg:
|
3187
|
-
|
3188
|
-
|
3189
|
-
return False
|
3144
|
+
_e_='can not connect at {0}:{1}\n{2}'.format(host,port,msg)
|
3145
|
+
printf(_e_,log=log,log_level=dbg,dsp='e')
|
3146
|
+
return False,_e_
|
3190
3147
|
|
3191
|
-
def net_start_server(server_port,main_func_name,server_ip='',timeout=0,max_connection=10,log_file=None,certfile=None,keyfile=None):
|
3148
|
+
def net_start_server(server_port,main_func_name,server_ip='',timeout=0,max_connection=10,log_file=None,certfile=None,keyfile=None,log=None):
|
3192
3149
|
ssoc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
3193
3150
|
ssoc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
3194
3151
|
if timeout > 0:
|
@@ -3196,10 +3153,10 @@ def net_start_server(server_port,main_func_name,server_ip='',timeout=0,max_conne
|
|
3196
3153
|
try:
|
3197
3154
|
ssoc.bind((server_ip, server_port))
|
3198
3155
|
except socket.error as msg:
|
3199
|
-
|
3156
|
+
printf('Bind failed. Error : {0}'.format(msg),log=log,mode='e',logfile=log_file)
|
3200
3157
|
os._exit(1)
|
3201
3158
|
ssoc.listen(max_connection)
|
3202
|
-
|
3159
|
+
printf('Start server for {0}:{1}'.format(server_ip,server_port),log=log,logfile=log_file)
|
3203
3160
|
# for handling task in separate jobs we need threading
|
3204
3161
|
while True:
|
3205
3162
|
conn, addr = ssoc.accept()
|
@@ -3211,10 +3168,10 @@ def net_start_server(server_port,main_func_name,server_ip='',timeout=0,max_conne
|
|
3211
3168
|
else:
|
3212
3169
|
Thread(target=main_func_name, args=(conn, ip, port, log_file)).start()
|
3213
3170
|
except:
|
3214
|
-
|
3171
|
+
printf('No more generate thread for client from {0}:{1}'.format(ip,port),dsp='e',log=log,logfile=log_file)
|
3215
3172
|
ssoc.close()
|
3216
3173
|
|
3217
|
-
def net_start_single_server(server_port,main_func_name,server_ip='',timeout=0,max_connection=10,log_file=None,certfile=None,keyfile=None):
|
3174
|
+
def net_start_single_server(server_port,main_func_name,server_ip='',timeout=0,max_connection=10,log_file=None,certfile=None,keyfile=None,log=None):
|
3218
3175
|
ssoc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
3219
3176
|
ssoc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
3220
3177
|
if timeout > 0:
|
@@ -3222,10 +3179,10 @@ def net_start_single_server(server_port,main_func_name,server_ip='',timeout=0,ma
|
|
3222
3179
|
try:
|
3223
3180
|
ssoc.bind((server_ip, server_port))
|
3224
3181
|
except socket.error as msg:
|
3225
|
-
|
3182
|
+
printf('Bind failed. Error : {0}'.format(msg),log=log,dsp='e',logfile=log_file)
|
3226
3183
|
os._exit(1)
|
3227
3184
|
ssoc.listen(max_connection)
|
3228
|
-
|
3185
|
+
printf('Start server for {0}:{1}'.format(server_ip,server_port),log=log,dsp='e',logfile=log_file)
|
3229
3186
|
# for handling task in separate jobs we need threading
|
3230
3187
|
conn, addr = ssoc.accept()
|
3231
3188
|
ip, port = str(addr[0]), str(addr[1])
|
@@ -3380,14 +3337,14 @@ def cert_file(keyfile,certfile,C='US',ST='CA',L='San Jose',O='KGC',OU='KG',CN=No
|
|
3380
3337
|
return key_file,crt_file
|
3381
3338
|
return None,None
|
3382
3339
|
|
3383
|
-
def net_put_data(IP,data,PORT=8805,key='kg',timeout=3,try_num=1,try_wait=[1,10],progress=None,enc=False,upacket=None,dbg=
|
3384
|
-
sent=False,'Unknown issue'
|
3340
|
+
def net_put_data(IP,data,PORT=8805,key='kg',timeout=3,try_num=1,try_wait=[1,10],progress=None,enc=False,upacket=None,dbg=6,wait_time=3,SSLC=False,instant=True,log=None):
|
3341
|
+
sent=False,'Unknown issue',None
|
3385
3342
|
for ii in range(0,try_num):
|
3386
3343
|
if upacket: # Update packet function for number of try information ([#/<total #>])
|
3387
3344
|
data=upacket('ntry',[ii+1,try_num],data)
|
3388
|
-
sock=net_get_socket(IP,PORT,timeout=timeout,dbg=dbg,SSLC=SSLC)
|
3345
|
+
ok,sock=net_get_socket(IP,PORT,timeout=timeout,dbg=dbg,SSLC=SSLC,log=log)
|
3389
3346
|
|
3390
|
-
if
|
3347
|
+
if ok is False:
|
3391
3348
|
if dbg >= 3:
|
3392
3349
|
print('Can not get socket data [{}/{}], wait {}s'.format(ii+1,try_num,wait_time))
|
3393
3350
|
else:
|
@@ -3395,21 +3352,21 @@ def net_put_data(IP,data,PORT=8805,key='kg',timeout=3,try_num=1,try_wait=[1,10],
|
|
3395
3352
|
sys.stdout.flush()
|
3396
3353
|
TIME().Sleep(wait_time)
|
3397
3354
|
continue
|
3398
|
-
sent=False,'Unknown issue'
|
3355
|
+
sent=False,'Unknown issue',sock
|
3399
3356
|
try:
|
3400
|
-
sent=net_send_data(sock,data,key=key,enc=enc)
|
3357
|
+
sent=net_send_data(sock,data,key=key,enc=enc,log=log)
|
3401
3358
|
except:
|
3402
|
-
|
3359
|
+
printf('send fail, try again ... [{}/{}]'.format(ii+1,try_num),log=log)
|
3403
3360
|
if sent[0]:
|
3404
|
-
if sock:
|
3361
|
+
if sock and instant:
|
3405
3362
|
sock.close()
|
3406
|
-
|
3363
|
+
sock=None
|
3364
|
+
return True,'sent',sock
|
3407
3365
|
if try_num > 1:
|
3408
3366
|
wait_time=Random(length=0,strs=try_wait,mode='int')
|
3409
|
-
|
3410
|
-
print('try send data ... [{}/{}], wait {}s'.format(ii+1,try_num,wait_time))
|
3367
|
+
printf('try send data ... [{}/{}], wait {}s'.format(ii+1,try_num,wait_time),log=log,log_level=dbg)
|
3411
3368
|
TIME().Sleep(wait_time)
|
3412
|
-
return
|
3369
|
+
return False,'Send fail({}) :\n{}'.format(sent[1],data),sock
|
3413
3370
|
|
3414
3371
|
|
3415
3372
|
def encode(string):
|
@@ -0,0 +1,6 @@
|
|
1
|
+
kmisc/__init__.py,sha256=hI9fY7diMWWo88eFi8xbSks6hju3rV54VsGrnGo0flo,152409
|
2
|
+
kmisc-2.1.88.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
|
3
|
+
kmisc-2.1.88.dist-info/METADATA,sha256=kDkEhPA7USFTTq5W02wjfXtujeNXOCvZnnSnl6bZ_KY,5522
|
4
|
+
kmisc-2.1.88.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
5
|
+
kmisc-2.1.88.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
|
6
|
+
kmisc-2.1.88.dist-info/RECORD,,
|
kmisc-2.1.86.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
kmisc/__init__.py,sha256=JbepqFeQ2fvhwXQvC5BYeflsM5eg8pLxOqfm-r-4sJQ,153332
|
2
|
-
kmisc-2.1.86.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
|
3
|
-
kmisc-2.1.86.dist-info/METADATA,sha256=wCEPueRWD0qvz_G7UX4hjq4L5oIX8Wwi-omEBxR81S0,5522
|
4
|
-
kmisc-2.1.86.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
5
|
-
kmisc-2.1.86.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
|
6
|
-
kmisc-2.1.86.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|