kmisc 2.1.111__py3-none-any.whl → 2.1.113__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 +113 -62
- {kmisc-2.1.111.dist-info → kmisc-2.1.113.dist-info}/METADATA +1 -1
- kmisc-2.1.113.dist-info/RECORD +6 -0
- kmisc-2.1.111.dist-info/RECORD +0 -6
- {kmisc-2.1.111.dist-info → kmisc-2.1.113.dist-info}/LICENSE +0 -0
- {kmisc-2.1.111.dist-info → kmisc-2.1.113.dist-info}/WHEEL +0 -0
- {kmisc-2.1.111.dist-info → kmisc-2.1.113.dist-info}/top_level.txt +0 -0
kmisc/__init__.py
CHANGED
@@ -905,63 +905,67 @@ class FILE:
|
|
905
905
|
return True
|
906
906
|
|
907
907
|
def MkTemp(self,filename=None,suffix='-XXXXXXXX',opt='dry',base_dir='/tmp',custom=None,force=False):
|
908
|
-
if
|
909
|
-
filename=
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
908
|
+
if isinstance(filename,str) and filename:
|
909
|
+
filename='{}{}'.format(filename,suffix)
|
910
|
+
return MkTemp(filename=filename,opt=opt,base_dir=base_dir,force=force)
|
911
|
+
#def MkTemp(self,filename=None,suffix='-XXXXXXXX',opt='dry',base_dir='/tmp',custom=None,force=False):
|
912
|
+
# if IsNone(filename):
|
913
|
+
# filename=os.path.join(base_dir,Random(length=len(suffix)-1,strs=custom,mode='str'))
|
914
|
+
# dir_name=os.path.dirname(filename)
|
915
|
+
# file_name=os.path.basename(filename)
|
916
|
+
# name, ext = os.path.splitext(file_name)
|
917
|
+
# if type(suffix) is not str or force is True:
|
918
|
+
# suffix='-XXXXXXXX'
|
919
|
+
# num_type='.%0{}d'.format(len(suffix)-1)
|
920
|
+
# if dir_name == '.':
|
921
|
+
# dir_name=os.path.dirname(os.path.realpath(__file__))
|
922
|
+
# elif dir_name == '':
|
923
|
+
# dir_name=base_dir
|
924
|
+
# def new_name(name,ext=None,ext2=None):
|
925
|
+
# if ext:
|
926
|
+
# if ext2:
|
927
|
+
# return '{}{}{}'.format(name,ext,ext2)
|
928
|
+
# return '{}{}'.format(name,ext)
|
929
|
+
# if ext2:
|
930
|
+
# return '{}{}'.format(name,ext2)
|
931
|
+
# return name
|
932
|
+
# def new_dest(dest_dir,name,ext=None,force=False):
|
933
|
+
# if os.path.isdir(dest_dir) is False:
|
934
|
+
# return False
|
935
|
+
# i=0
|
936
|
+
# new_file=new_name(name,ext)
|
937
|
+
# while True:
|
938
|
+
# rfile=os.path.join(dest_dir,new_file)
|
939
|
+
# if force is False and os.path.exists(rfile) is False:
|
940
|
+
# return rfile
|
941
|
+
# force=False
|
942
|
+
# if suffix:
|
943
|
+
# if '0' in suffix or 'n' in suffix or 'N' in suffix:
|
944
|
+
# if suffix[-1] not in ['0','n']:
|
945
|
+
# new_file=new_name(name,num_type%i,ext)
|
946
|
+
# else:
|
947
|
+
# new_file=new_name(name,ext,num_type%i)
|
948
|
+
# elif 'x' in suffix or 'X' in suffix:
|
949
|
+
# rnd_str='.{}'.format(Random(length=len(suffix)-1,mode='str'))
|
950
|
+
# if suffix[-1] not in ['X','x']:
|
951
|
+
# new_file=new_name(name,rnd_str,ext)
|
952
|
+
# else:
|
953
|
+
# new_file=new_name(name,ext,rnd_str)
|
954
|
+
# else:
|
955
|
+
# if i == 0:
|
956
|
+
# new_file=new_name(name,ext,'.{}'.format(suffix))
|
957
|
+
# else:
|
958
|
+
# new_file=new_name(name,ext,'.{}.{}'.format(suffix,i))
|
959
|
+
# else:
|
960
|
+
# new_file=new_name(name,ext,'.{}'.format(i))
|
961
|
+
# i+=1
|
962
|
+
# new_dest_file=new_dest(dir_name,name,ext,force=force)
|
963
|
+
# if opt in ['file','f']:
|
964
|
+
# os.mknode(new_dest_file)
|
965
|
+
# elif opt in ['dir','d','directory']:
|
966
|
+
# os.mkdir(new_dest_file)
|
967
|
+
# else:
|
968
|
+
# return new_dest_file
|
965
969
|
|
966
970
|
def SetIdentity(self,path,**opts):
|
967
971
|
if os.path.exists(path):
|
@@ -1808,8 +1812,10 @@ class SCREEN:
|
|
1808
1812
|
def Log(self,title,cmd):
|
1809
1813
|
# ipmitool -I lanplus -H 172.16.114.80 -U ADMIN -P ADMIN sol activate
|
1810
1814
|
pid=os.getpid()
|
1811
|
-
tmp_file=FILE().MkTemp('/tmp/.slc.{}_{}.cfg'.format(title,pid))
|
1812
|
-
log_file=FILE().MkTemp('/tmp/.screen_ck_{}_{}.log'.format(title,pid))
|
1815
|
+
#tmp_file=FILE().MkTemp('/tmp/.slc.{}_{}.cfg'.format(title,pid))
|
1816
|
+
#log_file=FILE().MkTemp('/tmp/.screen_ck_{}_{}.log'.format(title,pid))
|
1817
|
+
tmp_file=MkTemp('/tmp/.slc.{}_{}.cfg-XXXXXXXX'.format(title,pid))
|
1818
|
+
log_file=MkTemp('/tmp/.screen_ck_{}_{}.log-XXXXXXX'.format(title,pid))
|
1813
1819
|
if os.path.isfile(log_file):
|
1814
1820
|
log_file=''
|
1815
1821
|
with open(tmp_file,'w') as f:
|
@@ -2054,6 +2060,48 @@ def findXML(xmlfile,find_name=None,find_path=None,default=None,out='xmlobj',get_
|
|
2054
2060
|
return found_root[0]
|
2055
2061
|
return default
|
2056
2062
|
|
2063
|
+
def findPlanCfg(filename,find_name=None,default=False,original=False,date=None):
|
2064
|
+
# date format : include YYYY, MM, DD, hh, mm, ss information
|
2065
|
+
# Check File
|
2066
|
+
if date:
|
2067
|
+
finfo=InfoFile(filename)
|
2068
|
+
if isinstance(finfo,dict) and 'mtime' in finfo:
|
2069
|
+
# If old file then ignore
|
2070
|
+
if TIME(finfo.get('mtime')).Int() < TIME(date).Int():
|
2071
|
+
return default
|
2072
|
+
else:
|
2073
|
+
# Not found file then ignore
|
2074
|
+
return default
|
2075
|
+
# Passed date condition or no date condition then read the file
|
2076
|
+
data=cat(filename)
|
2077
|
+
if data is False:
|
2078
|
+
return default
|
2079
|
+
if find_name and isinstance(find_name,str):
|
2080
|
+
out=[]
|
2081
|
+
for ff in find_name.split(','):
|
2082
|
+
found=False
|
2083
|
+
for i in data.split('\n'):
|
2084
|
+
if isinstance(i,str) and '=' in i:
|
2085
|
+
i_a=i.split('=')
|
2086
|
+
if len(i_a) == 2 and i_a[0] == ff:
|
2087
|
+
found=True
|
2088
|
+
if original:
|
2089
|
+
out.append(i_a[1])
|
2090
|
+
else:
|
2091
|
+
if i_a[1][0] == '"' and i_a[1][-1] == '"':
|
2092
|
+
out.append(i_a[1][1:-1])
|
2093
|
+
elif i_a[1][0] == "'" and i_a[1][-1] == "'":
|
2094
|
+
out.append(i_a[1][1:-1])
|
2095
|
+
else:
|
2096
|
+
out.append(i_a[1])
|
2097
|
+
if not found:
|
2098
|
+
out.append(default)
|
2099
|
+
if len(out) == 1:
|
2100
|
+
return out[0]
|
2101
|
+
return out
|
2102
|
+
return data
|
2103
|
+
|
2104
|
+
|
2057
2105
|
def Compress(data,mode='lz4'):
|
2058
2106
|
if mode == 'lz4':
|
2059
2107
|
Import('from lz4 import frame')
|
@@ -2863,7 +2911,7 @@ def encode(string):
|
|
2863
2911
|
return '{0}'.format(base64.b64encode(tmp).decode('utf-8'))
|
2864
2912
|
except Exception as e:
|
2865
2913
|
printf('Issue for {}:\n{}'.format(string,e),mode='e')
|
2866
|
-
return False
|
2914
|
+
return False
|
2867
2915
|
|
2868
2916
|
def decode(string):
|
2869
2917
|
if type(string) is str:
|
@@ -2872,7 +2920,7 @@ def decode(string):
|
|
2872
2920
|
return '{0}'.format(dd.decode("utf-8"))
|
2873
2921
|
except Exception as e:
|
2874
2922
|
printf('Issue for {}:\n{}'.format(string,e),mode='e')
|
2875
|
-
return False
|
2923
|
+
return False
|
2876
2924
|
return string
|
2877
2925
|
|
2878
2926
|
def get_node_info(loop=0):
|
@@ -3220,7 +3268,10 @@ def sendanmail(to,subj,msg,html=True):
|
|
3220
3268
|
return Email.Send(to,sender='root@sumtester.supermicro.com',title=subj,msg=msg,html=html)
|
3221
3269
|
|
3222
3270
|
def mktemp(filename=None,suffix='-XXXXXXXX',opt='dry',base_dir='/tmp',force=False):
|
3223
|
-
return FILE().MkTemp(filename=filename,suffix=suffix,opt=opt,base_dir=base_dir,force=force)
|
3271
|
+
#return FILE().MkTemp(filename=filename,suffix=suffix,opt=opt,base_dir=base_dir,force=force)
|
3272
|
+
if isinstance(filename,str) and filename:
|
3273
|
+
filename='{}{}'.format(filename,suffix)
|
3274
|
+
return MkTemp(filename=filename,opt=opt,base_dir=base_dir,force=force)
|
3224
3275
|
|
3225
3276
|
def get_host_name():
|
3226
3277
|
return HOST().Name()
|
@@ -0,0 +1,6 @@
|
|
1
|
+
kmisc/__init__.py,sha256=emQKkxfqVCMDcfAw_rK-V7R6pLQR4KyOK4pr4-FvtDU,137902
|
2
|
+
kmisc-2.1.113.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
|
3
|
+
kmisc-2.1.113.dist-info/METADATA,sha256=G8rSKNOZ5bCu0lv63QiG3ZlqzXxIABUx0wmaK2CxYuw,5523
|
4
|
+
kmisc-2.1.113.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
5
|
+
kmisc-2.1.113.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
|
6
|
+
kmisc-2.1.113.dist-info/RECORD,,
|
kmisc-2.1.111.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
kmisc/__init__.py,sha256=DrazyN4Ku-mi5iRFDUBBAaN7Dl2m7-yuJb-70n6bGiI,135659
|
2
|
-
kmisc-2.1.111.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
|
3
|
-
kmisc-2.1.111.dist-info/METADATA,sha256=tZKVamycHTGePi6CqHSMN4_i0ZAiDnQSa1fWKOty_rQ,5523
|
4
|
-
kmisc-2.1.111.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
5
|
-
kmisc-2.1.111.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
|
6
|
-
kmisc-2.1.111.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|