Adding categories for Weekly and Monthly to categorize.py
This commit is contained in:
parent
8c762e83a1
commit
dd8d82fdac
@ -13,15 +13,28 @@ import time
|
||||
import datetime
|
||||
import re
|
||||
|
||||
global TSformat
|
||||
TSformat = '%Y:%m:%d_%H:%M:%S'
|
||||
##
|
||||
# get difference in seconds between two time stamps
|
||||
def tsdiff(ts1,ts2):
|
||||
TSformat = '%Y:%m:%d_%H:%M:%S' #
|
||||
global TSformat
|
||||
# print(time.mktime(time.strptime(re.sub('\.[0-9]*','',ts1),TSformat)))
|
||||
return abs( time.mktime(time.strptime(re.sub('\.[0-9]*','',ts1),TSformat)) \
|
||||
- time.mktime(time.strptime(re.sub('\.[0-9]*','',ts2),TSformat)) \
|
||||
)
|
||||
|
||||
def year_month(ts):
|
||||
global TSformat
|
||||
t=time.strptime(re.sub('\.[0-9]*','',ts),TSformat)
|
||||
return str(t.tm_year)+':'+str(t.tm_mon)
|
||||
|
||||
def year_week(ts):
|
||||
global TSformat
|
||||
t=time.strptime(re.sub('\.[0-9]*','',ts),TSformat)
|
||||
w=datetime.date(t.tm_year, t.tm_mon, t.tm_mday).isocalendar()[1]
|
||||
return str(t.tm_year)+':'+str(w)
|
||||
|
||||
##
|
||||
#
|
||||
def mkdir(P):
|
||||
@ -31,7 +44,7 @@ def mkdir(P):
|
||||
|
||||
##
|
||||
#
|
||||
def remake(P):
|
||||
def rmdir_mkdir(P):
|
||||
if os.path.exists(P):
|
||||
shutil.rmtree(P,ignore_errors=True)
|
||||
mkdir(P)
|
||||
@ -43,52 +56,60 @@ def visitfile(file,path,myData):
|
||||
"""visitfile - use by the directory walker"""
|
||||
# print("file,path = " , file , " -> ",path)
|
||||
global latest,sweep
|
||||
global Platform, Version, Date, Monthly, Weekly
|
||||
|
||||
home = myData['home' ]
|
||||
|
||||
if os.path.isfile(path):
|
||||
try:
|
||||
# parse exiv2-0.27.0.1-CYGWIN-2018:10:19_01:13:00.tar.gz
|
||||
# print('file = ' + file)
|
||||
splits = file.split('-')
|
||||
if file.find('MinGW') != -1:
|
||||
platform = splits[2]+'-'+splits[3]
|
||||
date = splits[4].split('.')[0]
|
||||
version = splits[1]
|
||||
else:
|
||||
platform = splits[2]
|
||||
date = splits[3].split('.')[0]
|
||||
version = splits[1]
|
||||
# print( "%s -> platform = %s version = %s date = %s " % (file , platform,version,date) )
|
||||
# parse exiv2-0.27.0.1-CYGWIN-2018:10:19_01:13:00.tar.gz
|
||||
# print('file = ' + file)
|
||||
splits = file.split('-')
|
||||
if file.find('MinGW') != -1:
|
||||
platform = splits[2]+'-'+splits[3]
|
||||
date = splits[4].split('.')[0]
|
||||
version = splits[1]
|
||||
else:
|
||||
platform = splits[2]
|
||||
date = splits[3].split('.')[0]
|
||||
version = splits[1]
|
||||
monthly= year_month(date)
|
||||
weekly = year_week(date)
|
||||
# print( "%s -> platform = %s version = %s date = %s " % (file , platform,version,date) )
|
||||
|
||||
myData ['platform'].add(platform)
|
||||
myData ['date' ].add(date )
|
||||
myData ['version' ].add(version )
|
||||
myData ['platform'].add(platform)
|
||||
myData ['date' ].add(date )
|
||||
myData ['version' ].add(version )
|
||||
myData ['weekly' ].add(monthly )
|
||||
myData ['monthly' ].add(weekly )
|
||||
|
||||
if sweep==1:
|
||||
Platform = os.path.join(home,'Platform')
|
||||
Date = os.path.join(home,'Date' )
|
||||
Version = os.path.join(home,'Version' )
|
||||
Latest = os.path.join(home,'Latest' )
|
||||
if sweep==1:
|
||||
Links = { Platform:platform, Date:date, Version:version, Monthly:monthly, Weekly:weekly }
|
||||
for L in Links:
|
||||
# path : all/exiv2-0.27.0.1-MSVC-2018:10:20_06:33:13.zip
|
||||
# file : exiv2-0.27.0.1-MSVC-2018:10:20_06:33:13.zip
|
||||
# L : /Users/rmills/Jenkins/builds/Platform
|
||||
# Links[L]: MSVC
|
||||
# Link : /Users/rmills/Jenkins/builds/Platform/MSVC
|
||||
# file : exiv2-0.27.0.1-MSVC-2018:10:20_06:33:13.zip
|
||||
# ls -s all/exiv2-0.27.0.1-MSVC-2018:10:20_06:33:13.zip \
|
||||
# Platform/MSVC/exiv2-0.27.0.1-MSVC-2018:10:20_06:33:13.zip
|
||||
Link=os.path.join(L,Links[L])
|
||||
mkdir(Link)
|
||||
os.symlink(path,os.path.join(Link,file))
|
||||
if ( 1 == 2 ):
|
||||
print('path : %s' % path )
|
||||
print('file : %s' % file )
|
||||
print('L : %s' % L )
|
||||
print('Links[L]: %s' % Links[L])
|
||||
print('Link : %s' % Link )
|
||||
print('file : %s' % file )
|
||||
print('ls -s %s %s' % (path,os.path.join(Link,file)) )
|
||||
exit(0)
|
||||
|
||||
P=os.path.join(Platform,platform)
|
||||
mkdir(P)
|
||||
os.symlink(path,os.path.join(P,file))
|
||||
|
||||
D=os.path.join(Date,date)
|
||||
mkdir(D)
|
||||
os.symlink(path,os.path.join(D,file))
|
||||
|
||||
V=os.path.join(Version,version)
|
||||
mkdir(V)
|
||||
os.symlink(path,os.path.join(V,file))
|
||||
|
||||
# print('latest? file = %s date = %s latest = %s DIFF = %d' % (file,date,latest_date,0)) # tsdiff(date,latest) ))
|
||||
if tsdiff(date,latest) < 5:
|
||||
# print('linking file = %s path = %s Latest = %s' % (file,path,Latest ))
|
||||
os.symlink(path,os.path.join(Latest,file))
|
||||
|
||||
except:
|
||||
pass
|
||||
# print('latest? file = %s date = %s latest = %s DIFF = %d' % (file,date,latest_date,0)) # tsdiff(date,latest) ))
|
||||
if tsdiff(date,latest) < 5:
|
||||
# print('linking file = %s path = %s Latest = %s' % (file,path,Latest ))
|
||||
os.symlink(path,os.path.join(Latest,file))
|
||||
##
|
||||
|
||||
##
|
||||
@ -96,6 +117,7 @@ def visitfile(file,path,myData):
|
||||
def searcher(home):
|
||||
"""searcher - walk the tree"""
|
||||
global latest,sweep
|
||||
global Platform, Version, Latest, Date, Monthly, Weekly
|
||||
|
||||
print("home = " , home)
|
||||
|
||||
@ -105,6 +127,8 @@ def searcher(home):
|
||||
myData ['platform']=set()
|
||||
myData ['version' ]=set()
|
||||
myData ['date' ]=set()
|
||||
myData ['monthly' ]=set()
|
||||
myData ['weekly' ]=set()
|
||||
|
||||
for sweep in range(0,1+1):
|
||||
# sweep == 0 : ignore links and populate myData
|
||||
@ -131,18 +155,34 @@ def searcher(home):
|
||||
version.sort()
|
||||
# print(version)
|
||||
|
||||
weekly = list(myData['weekly'])
|
||||
weekly.sort()
|
||||
# print(weekly)
|
||||
|
||||
monthly = list(myData['monthly'])
|
||||
monthly.sort()
|
||||
|
||||
if sweep==0:
|
||||
Platform = os.path.join(home,'Platform')
|
||||
Date = os.path.join(home,'Date' )
|
||||
Latest = os.path.join(home,'Latest' )
|
||||
Version = os.path.join(home,"Version" )
|
||||
Weekly = os.path.join(home,"Weekly" )
|
||||
Monthly = os.path.join(home,"Monthly" )
|
||||
Source = os.path.join(home,"Source" )
|
||||
|
||||
remake(Platform)
|
||||
remake(Date)
|
||||
remake(Version)
|
||||
remake(Latest)
|
||||
rmdir_mkdir(Platform)
|
||||
rmdir_mkdir(Date )
|
||||
rmdir_mkdir(Latest )
|
||||
rmdir_mkdir(Version )
|
||||
rmdir_mkdir(Weekly )
|
||||
rmdir_mkdir(Monthly )
|
||||
|
||||
print("Latest: ",latest)
|
||||
# ln -s Platform/Source Source
|
||||
if ( os.path.exists(Source) ):
|
||||
os.unlink (Source)
|
||||
os.symlink(os.path.join(Platform,'Source'),Source )
|
||||
|
||||
# print(myData ['date' ])
|
||||
##
|
||||
|
||||
Loading…
Reference in New Issue
Block a user