kmisc 2.1.112__tar.gz → 2.1.114__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kmisc
3
- Version: 2.1.112
3
+ Version: 2.1.114
4
4
  Summary: Enginering useful library
5
5
  Home-page: https://github.com/kagepark/kmisc
6
6
  Author: Kage Park
@@ -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 IsNone(filename):
909
- filename=os.path.join(base_dir,Random(length=len(suffix)-1,strs=custom,mode='str'))
910
- dir_name=os.path.dirname(filename)
911
- file_name=os.path.basename(filename)
912
- name, ext = os.path.splitext(file_name)
913
- if type(suffix) is not str or force is True:
914
- suffix='-XXXXXXXX'
915
- num_type='.%0{}d'.format(len(suffix)-1)
916
- if dir_name == '.':
917
- dir_name=os.path.dirname(os.path.realpath(__file__))
918
- elif dir_name == '':
919
- dir_name=base_dir
920
- def new_name(name,ext=None,ext2=None):
921
- if ext:
922
- if ext2:
923
- return '{}{}{}'.format(name,ext,ext2)
924
- return '{}{}'.format(name,ext)
925
- if ext2:
926
- return '{}{}'.format(name,ext2)
927
- return name
928
- def new_dest(dest_dir,name,ext=None,force=False):
929
- if os.path.isdir(dest_dir) is False:
930
- return False
931
- i=0
932
- new_file=new_name(name,ext)
933
- while True:
934
- rfile=os.path.join(dest_dir,new_file)
935
- if force is False and os.path.exists(rfile) is False:
936
- return rfile
937
- force=False
938
- if suffix:
939
- if '0' in suffix or 'n' in suffix or 'N' in suffix:
940
- if suffix[-1] not in ['0','n']:
941
- new_file=new_name(name,num_type%i,ext)
942
- else:
943
- new_file=new_name(name,ext,num_type%i)
944
- elif 'x' in suffix or 'X' in suffix:
945
- rnd_str='.{}'.format(Random(length=len(suffix)-1,mode='str'))
946
- if suffix[-1] not in ['X','x']:
947
- new_file=new_name(name,rnd_str,ext)
948
- else:
949
- new_file=new_name(name,ext,rnd_str)
950
- else:
951
- if i == 0:
952
- new_file=new_name(name,ext,'.{}'.format(suffix))
953
- else:
954
- new_file=new_name(name,ext,'.{}.{}'.format(suffix,i))
955
- else:
956
- new_file=new_name(name,ext,'.{}'.format(i))
957
- i+=1
958
- new_dest_file=new_dest(dir_name,name,ext,force=force)
959
- if opt in ['file','f']:
960
- os.mknode(new_dest_file)
961
- elif opt in ['dir','d','directory']:
962
- os.mkdir(new_dest_file)
963
- else:
964
- return new_dest_file
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,13 +2060,27 @@ 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
 
2057
- def findPlanCfg(filename,find_name=None,default=False,original=False):
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
2058
2076
  data=cat(filename)
2059
2077
  if data is False:
2060
2078
  return default
2061
- if find_name and isinstance(find_name,str):
2079
+ if find_name:
2080
+ if isinstance(find_name,str):
2081
+ find_name=find_name.split(',')
2062
2082
  out=[]
2063
- for ff in find_name.split(','):
2083
+ for ff in find_name:
2064
2084
  found=False
2065
2085
  for i in data.split('\n'):
2066
2086
  if isinstance(i,str) and '=' in i:
@@ -3250,7 +3270,10 @@ def sendanmail(to,subj,msg,html=True):
3250
3270
  return Email.Send(to,sender='root@sumtester.supermicro.com',title=subj,msg=msg,html=html)
3251
3271
 
3252
3272
  def mktemp(filename=None,suffix='-XXXXXXXX',opt='dry',base_dir='/tmp',force=False):
3253
- return FILE().MkTemp(filename=filename,suffix=suffix,opt=opt,base_dir=base_dir,force=force)
3273
+ #return FILE().MkTemp(filename=filename,suffix=suffix,opt=opt,base_dir=base_dir,force=force)
3274
+ if isinstance(filename,str) and filename:
3275
+ filename='{}{}'.format(filename,suffix)
3276
+ return MkTemp(filename=filename,opt=opt,base_dir=base_dir,force=force)
3254
3277
 
3255
3278
  def get_host_name():
3256
3279
  return HOST().Name()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kmisc
3
- Version: 2.1.112
3
+ Version: 2.1.114
4
4
  Summary: Enginering useful library
5
5
  Home-page: https://github.com/kagepark/kmisc
6
6
  Author: Kage Park
File without changes
File without changes
File without changes
File without changes
File without changes