This commit is contained in:
dennis 2022-10-27 08:37:53 +02:00
parent ec95220f9b
commit 72483a854a
3 changed files with 41 additions and 22 deletions

View File

@ -1,6 +1,7 @@
from sqlalchemy import Table, Column, Integer, String,MetaData,select,insert,NVARCHAR from sqlalchemy import Table, Column, Integer, String,MetaData,select,insert,NVARCHAR
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base; from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Session
Base = declarative_base() Base = declarative_base()
@ -18,8 +19,8 @@ class LabelHandler:
Base.metadata.create_all(self.engine) Base.metadata.create_all(self.engine)
Session = sessionmaker(bind=self.engine) #Session = sessionmaker(bind=self.engine)
session = Session() session = Session(self.engine, future=True)
meta = MetaData() meta = MetaData()
meta.reflect(bind=self.engine) meta.reflect(bind=self.engine)
listDeployedLabels=meta.tables['ListDeployedLabels'] listDeployedLabels=meta.tables['ListDeployedLabels']
@ -28,14 +29,17 @@ class LabelHandler:
__mapper_args__ = { __mapper_args__ = {
'primary_key':[listDeployedLabels.c.Project] 'primary_key':[listDeployedLabels.c.Project]
} }
statement=select(ListDeployedLabels).join(PropertyNamesChecked,PropertyNamesChecked.Project==ListDeployedLabels.Project)
res=session.query(ListDeployedLabels).join(PropertyNamesChecked,PropertyNamesChecked.Project==ListDeployedLabels.Project)
listOfUncheckedPropertyNames = [] listOfUncheckedPropertyNames=session.execute(statement).scalars().all()
for r in res:
listOfUncheckedPropertyNames.append(r)
return listOfUncheckedPropertyNames return listOfUncheckedPropertyNames
def markAsChecked(): def markAsChecked(self):
pass pass
def getLabel(self,listDeployedLabels:Base):
strLabel=""
strLabel=listDeployedLabels.CurrentVersion.split(':')[2].strip()
return strLabel

View File

@ -1,11 +1,14 @@
from sqlalchemy import create_engine from sqlalchemy import create_engine
import urllib import urllib
from LabelHandler import LabelHandler from LabelHandler import LabelHandler
from TfsHandler import TfsHandler
server = 'bi-dsa-udv\dsa' # to specify an alternate port server = 'bi-dsa-udv\dsa' # to specify an alternate port
database = 'udv_denker' database = 'udv_denker'
username = 'admindenker' username = 'admindenker'
password = 'biadmin#kode4meO9' password = 'biadmin#kode4meO9'
tfsBasePath=r'F:\Users\admindenker\TFS Workspace'
tfPath=r'c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE'
connection_string = "DRIVER={SQL Server};Database="+database+";SERVER="+server connection_string = "DRIVER={SQL Server};Database="+database+";SERVER="+server
connection_string = urllib.parse.quote_plus(connection_string) connection_string = urllib.parse.quote_plus(connection_string)
@ -13,7 +16,11 @@ connection_string = "mssql+pyodbc:///?odbc_connect=%s" % connection_string
engine = create_engine(connection_string, echo = True) engine = create_engine(connection_string, echo = True)
labelHandler = LabelHandler(engine) labelHandler = LabelHandler(engine)
tfsHandler = TfsHandler(tfPath,tfsBasePath)
newReleases=labelHandler.getNewReleases() newReleases=labelHandler.getNewReleases()
for a in newReleases:
print(labelHandler.getLabel(a))
path=tfsHandler.getProjectPath(labelHandler.getLabel(a))
print("done") print("done")

View File

@ -1,12 +1,14 @@
from pathlib import Path from pathlib import Path
import subprocess
class TfsHandler(): class TfsHandler():
def __init__(self,path): def __init__(self,tfPath,tfsBasePath):
self.path=Path(path) self.tfPath=Path(tfPath)
self.tfsBasePath=Path(tfsBasePath)
def checkPropertyName(self): def checkPropertyName(self):
pass pass
def updateRepository(self): def updateRepository(self):
pass pass
def checkFile(file): def checkFile(self, file):
f=open(file,"r", encoding='utf-8') f=open(file,"r", encoding='utf-8')
for x in f: for x in f:
if(x.find("DTS:ObjectName")>-1): if(x.find("DTS:ObjectName")>-1):
@ -25,17 +27,23 @@ class TfsHandler():
ssisproject=[a for a in file.parts if a.find("SSIS_")>-1] ssisproject=[a for a in file.parts if a.find("SSIS_")>-1]
if(len(ssisproject)>0): if(len(ssisproject)>0):
#insertOrUpdateTable(ssisproject[0],str(file.parent),str(file.stem),propertyNameToken) #insertOrUpdateTable(ssisproject[0],str(file.parent),str(file.stem),propertyNameToken)
insertIntoTable(ssisproject[0],str(file.parent),str(file.stem),propertyNameToken) # insertIntoTable(ssisproject[0],str(file.parent),str(file.stem),propertyNameToken)
print(ssisproject[0] + ' ' + str(file.parent) + ' ' + file.stem + ' ' + propertyNameToken) print(ssisproject[0] + ' ' + str(file.parent) + ' ' + file.stem + ' ' + propertyNameToken)
print(x) print(x)
break break
else: else:
continue continue
f.close() f.close()
def updateRepo(self,path):
# def traverseDirectory(x): project=''
# if (x.name=='obj' or x.name.strip()=='DataPresentationArea' or x.name=='FastTrack' or x.name=='Undervisning' or x.name=='Udvikling'): def getProjectPath(self,label):
# # print(x.name) labelInfo=subprocess.run([str(self.tfPath.joinpath('tf.exe')),"vc","labels","/owner:*","/format:detailed",label],stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True,text=True)
# return if(len(labelInfo.stdout)>0):
# [checkFile(z) for z in x.iterdir() if z.is_file and z.name.endswith('.dtsx')] relativePath=labelInfo.stdout.split('\n')[9].split('$')[1]
# [traverseDirectory(y) for y in x.iterdir() if y.is_dir()] return self.tfsBasePath.joinpath(relativePath.removeprefix('/'))
def traverseDirectory(x):
if (x.name=='obj' or x.name.strip()=='DataPresentationArea' or x.name=='FastTrack' or x.name=='Undervisning' or x.name=='Udvikling'):
print(x.name)
return
[checkFile(z) for z in x.iterdir() if z.is_file and z.name.endswith('.dtsx')]
[traverseDirectory(y) for y in x.iterdir() if y.is_dir()]