From ec95220f9b56fb991a747c0da379ff185587a310 Mon Sep 17 00:00:00 2001 From: dennis Date: Mon, 24 Oct 2022 14:43:12 +0200 Subject: [PATCH] upload --- LabelHandler.py | 41 ++++++++++++++++++++++++ RepositoryAutoCheck.py | 21 ++++++++++++ TfsHandler.py | 41 ++++++++++++++++++++++++ __pycache__/LabelHandler.cpython-37.pyc | Bin 0 -> 1938 bytes 4 files changed, 103 insertions(+) create mode 100644 LabelHandler.py create mode 100644 RepositoryAutoCheck.py create mode 100644 TfsHandler.py create mode 100644 __pycache__/LabelHandler.cpython-37.pyc diff --git a/LabelHandler.py b/LabelHandler.py new file mode 100644 index 0000000..95a272a --- /dev/null +++ b/LabelHandler.py @@ -0,0 +1,41 @@ +from sqlalchemy import Table, Column, Integer, String,MetaData,select,insert,NVARCHAR +from sqlalchemy.orm import sessionmaker +from sqlalchemy.ext.declarative import declarative_base; +Base = declarative_base() + + +class LabelHandler: + + def __init__(self,engine) -> None: + self.engine=engine + + def getNewReleases(self): + class PropertyNamesChecked(Base): + __tablename__ = 'PropertyNamesChecked' + id = Column(Integer, primary_key=True) + Project = Column(NVARCHAR(length=100)) + CurrentVersion = Column(NVARCHAR(length=145)) + + Base.metadata.create_all(self.engine) + + Session = sessionmaker(bind=self.engine) + session = Session() + meta = MetaData() + meta.reflect(bind=self.engine) + listDeployedLabels=meta.tables['ListDeployedLabels'] + class ListDeployedLabels(Base): + __table__=listDeployedLabels + __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) + return listOfUncheckedPropertyNames + + + def markAsChecked(): + pass \ No newline at end of file diff --git a/RepositoryAutoCheck.py b/RepositoryAutoCheck.py new file mode 100644 index 0000000..7a5f9a7 --- /dev/null +++ b/RepositoryAutoCheck.py @@ -0,0 +1,21 @@ +from sqlalchemy import create_engine +import urllib +from LabelHandler import LabelHandler + +server = 'bi-dsa-udv\dsa' # to specify an alternate port +database = 'udv_denker' +username = 'admindenker' +password = 'biadmin#kode4meO9' + +connection_string = "DRIVER={SQL Server};Database="+database+";SERVER="+server +connection_string = urllib.parse.quote_plus(connection_string) +connection_string = "mssql+pyodbc:///?odbc_connect=%s" % connection_string +engine = create_engine(connection_string, echo = True) + +labelHandler = LabelHandler(engine) +newReleases=labelHandler.getNewReleases() + + +print("done") + + diff --git a/TfsHandler.py b/TfsHandler.py new file mode 100644 index 0000000..ec66ce0 --- /dev/null +++ b/TfsHandler.py @@ -0,0 +1,41 @@ +from pathlib import Path +class TfsHandler(): + def __init__(self,path): + self.path=Path(path) + def checkPropertyName(self): + pass + def updateRepository(self): + pass + def checkFile(file): + f=open(file,"r", encoding='utf-8') + for x in f: + if(x.find("DTS:ObjectName")>-1): + propertyNameTokens=x.split('=') + count=0 + propertyNameToken=None + while count < len(propertyNameTokens): + if(propertyNameTokens[count].find("DTS:ObjectName")>-1): + propertyNameToken=propertyNameTokens[count+1].split('"')[1] + break + count+=2 + if(propertyNameToken==None): + print(f"propertyNameToken findes ikke i {file.name}") + continue + if(file.stem!=propertyNameToken): + 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) + 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()] \ No newline at end of file diff --git a/__pycache__/LabelHandler.cpython-37.pyc b/__pycache__/LabelHandler.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b952acdf0e6cd8381eaf2417cb86681a6983fa1e GIT binary patch literal 1938 zcma)7OK%%D5GMC6S(07XEgIJ-+FMkhy7qxIh$90{fmBVMM+-v5V!fp0mG&W%R2mtp zlZ_NTJX(S_^JQd+Vq(qF* zE!%4sKZhMb80CanoO0_G+~)y|E~j90%{1;u2O_-}8t z=!wi@YoQxQ>|N*zK`v=YLcj;E)9QlA2T3m4mT|zJL)n5ee-XI>!#}81+`l!hJ`(j+EL>F?pJJCh=NW`Q5b>lkYsR_a`$rBxh zHMFKOk)C|8a%y=Zrf>us9)*w~h>>~)0>}eofILf+Q+q}=8PapBBt!dxQlcH4ar*_G zS*3MKX0~=gI;Au8mR~4=mCv0UYfz8Q`nO&wnPR50HAj6=EH*_YNBV6^JWhnJpaQatq9~ zmFZW4VJ{>i}Lf25!Pg4pbOcK7%`( z>06G>;i!;6>rtaZGyw^#-7wBwpxgu*)F6&Es2)oZX%R+gT4k=p6qg{ z%DBf9A*aR}7D-;&Wjr)0=k1zY$7={Z^B>MDm+==R%sBX(L~D#Kg-^B9v{ z@Ra~FR4%-epQ29m#I#l;wgGzzJtK6(YgrBI!LLQ@bj#lc!s{?U`S^cWSs@$iL>Cnz zN{g~~EvB%JU14gP5b>kkWpdoady6u(z4GA7v9|XH$8r<3eu1L%TL0=x5}ov+D