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.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()
@ -18,8 +19,8 @@ class LabelHandler:
Base.metadata.create_all(self.engine)
Session = sessionmaker(bind=self.engine)
session = Session()
#Session = sessionmaker(bind=self.engine)
session = Session(self.engine, future=True)
meta = MetaData()
meta.reflect(bind=self.engine)
listDeployedLabels=meta.tables['ListDeployedLabels']
@ -28,14 +29,17 @@ class LabelHandler:
__mapper_args__ = {
'primary_key':[listDeployedLabels.c.Project]
}
res=session.query(ListDeployedLabels).join(PropertyNamesChecked,PropertyNamesChecked.Project==ListDeployedLabels.Project)
listOfUncheckedPropertyNames = []
for r in res:
listOfUncheckedPropertyNames.append(r)
statement=select(ListDeployedLabels).join(PropertyNamesChecked,PropertyNamesChecked.Project==ListDeployedLabels.Project)
listOfUncheckedPropertyNames=session.execute(statement).scalars().all()
return listOfUncheckedPropertyNames
def markAsChecked():
pass
def markAsChecked(self):
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
import urllib
from LabelHandler import LabelHandler
from TfsHandler import TfsHandler
server = 'bi-dsa-udv\dsa' # to specify an alternate port
database = 'udv_denker'
username = 'admindenker'
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 = 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)
labelHandler = LabelHandler(engine)
tfsHandler = TfsHandler(tfPath,tfsBasePath)
newReleases=labelHandler.getNewReleases()
for a in newReleases:
print(labelHandler.getLabel(a))
path=tfsHandler.getProjectPath(labelHandler.getLabel(a))
print("done")

View File

@ -1,12 +1,14 @@
from pathlib import Path
import subprocess
class TfsHandler():
def __init__(self,path):
self.path=Path(path)
def __init__(self,tfPath,tfsBasePath):
self.tfPath=Path(tfPath)
self.tfsBasePath=Path(tfsBasePath)
def checkPropertyName(self):
pass
def updateRepository(self):
pass
def checkFile(file):
def checkFile(self, file):
f=open(file,"r", encoding='utf-8')
for x in f:
if(x.find("DTS:ObjectName")>-1):
@ -25,17 +27,23 @@ class TfsHandler():
ssisproject=[a for a in file.parts if a.find("SSIS_")>-1]
if(len(ssisproject)>0):
#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(x)
break
else:
continue
f.close()
# 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()]
def updateRepo(self,path):
project=''
def getProjectPath(self,label):
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)
if(len(labelInfo.stdout)>0):
relativePath=labelInfo.stdout.split('\n')[9].split('$')[1]
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()]