8000 TSC-152 #time 1h moving password argument to startup and fixing branc… · onware/document-api-python@ff8a862 · GitHub
[go: up one dir, main page]

Skip to content

Commit ff8a862

Browse files
author
Sam Bao
committed
TSC-152 #time 1h moving password argument to startup and fixing branch parsing issue
1 parent 3daff18 commit ff8a862

File tree

6 files changed

+43
-30
lines changed

6 files changed

+43
-30
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
Workbook,Format,Project,Branch,Directory,PublishDate,ModifiedDate
2-
Job Time,.twbx,Operations - Edmonton,Edmonton,/thorpespecialtyservicescorporation/projects/113334/workbooks,2018-08-29 15:20:34,
3-
Job Time,.twbx,Operations - Abbotsford-Cor,Abbotsford-Cor,/thorpespecialtyservicescorporation/projects/113330/workbooks,2018-08-29 15:20:53,
4-
Job Time,.twbx,Operations - Abbotsford-Ref,Abbotsford-Ref,/thorpespecialtyservicescorporation/projects/113331/workbooks,2018-08-29 15:21:11,
5-
Job Time,.twbx,Operations - Birmingham,Birmingham,/thorpespecialtyservicescorporation/projects/113347/workbooks,2018-08-29 15:21:27,
6-
Job Time,.twbx,Operations - Corpus Christi,Corpus Christi,/thorpespecialtyservicescorporation/projects/113333/workbooks,2018-08-29 15:21:43,
7-
Job Time,.twbx,Operations - Engineered Products,Engineered Products,/thorpespecialtyservicescorporation/projects/113335/workbooks,2018-08-29 15:22:00,
8-
Job Time,.twbx,Operations - Flooring,Flooring,/thorpespecialtyservicescorporation/projects/113336/workbooks,2018-08-29 15:22:15,
9-
Job Time,.twbx,Operations - Harrison,Harrison,/thorpespecialtyservicescorporation/projects/113337/workbooks,2018-08-29 15:22:34,
10-
Job Time,.twbx,Operations - Houston-Cor,Houston-Cor,/thorpespecialtyservicescorporation/projects/113338/workbooks,2018-08-29 15:22:52,
11-
Job Time,.twbx,Operations - Houston-Ref,Houston-Ref,/thorpespecialtyservicescorporation/projects/113339/workbooks,2018-08-29 15:23:09,
12-
Job Time,.twbx,Operations - International,International,/thorpespecialtyservicescorporation/projects/113340/workbooks,2018-08-29 15:23:26,
13-
Job Time,.twbx,Operations - JT-Beaumont,JT-Beaumont,/thorpespecialtyservicescorporation/projects/113356/workbooks,2018-08-29 15:23:44,
14-
Job Time,.twbx,Operations - JT-Houston,JT-Houston,/thorpespecialtyservicescorporation/projects/113341/workbooks,2018-08-29 15:24:02,
15-
Job Time,.twbx,Operations - St. Gabriel-Cor,St. Gabriel-Cor,/thorpespecialtyservicescorporation/projects/113342/workbooks,2018-08-29 15:24:18,
16-
Job Time,.twbx,Operations - St. Gabriel-Ref,St. Gabriel-Ref,/thorpespecialtyservicescorporation/projects/113343/workbooks,2018-08-29 15:24:34,
17-
Job Time,.twbx,Operations - Tulsa,Tulsa,/thorpespecialtyservicescorporation/projects/113344/workbooks,2018-08-29 15:24:51,
2+
Job Cost Inquiry,.twbx,Operations - Edmonton,Edmonton,/thorpespecialtyservicescorporation/projects/113334/workbooks,2018-08-30 12:46:30,
3+
Job Cost Inquiry,.twbx,Operations - Abbotsford-Cor,Abbotsford-Cor,/thorpespecialtyservicescorporation/projects/113330/workbooks,2018-08-30 12:47:20,
4+
Job Cost Inquiry,.twbx,Operations - Abbotsford-Ref,Abbotsford-Ref,/thorpespecialtyservicescorporation/projects/113331/workbooks,2018-08-30 12:47:44,
5+
Job Cost Inquiry,.twbx,Operations - Birmingham,Birmingham,/thorpespecialtyservicescorporation/projects/113347/workbooks,2018-08-30 12:48:11,
6+
Job Cost Inquiry,.twbx,Operations - Corpus Christi,Corpus Christi,/thorpespecialtyservicescorporation/projects/113333/workbooks,2018-08-30 12:48:35,
7+
Job Cost Inquiry,.twbx,Operations - Engineered Products,Engineered Products,/thorpespecialtyservicescorporation/projects/113335/workbooks,2018-08-30 12:48:58,
8+
Job Cost Inquiry,.twbx,Operations - Flooring,Flooring,/thorpespecialtyservicescorporation/projects/113336/workbooks,2018-08-30 12:49:21,
9+
Job Cost Inquiry,.twbx,Operations - Harrison,Harrison,/thorpespecialtyservicescorporation/projects/113337/workbooks,2018-08-30 12:49:43,
10+
Job Cost Inquiry,.twbx,Operations - Houston-Cor,Houston-Cor,/thorpespecialtyservicescorporation/projects/113338/workbooks,2018-08-30 12:50:05,
11+
Job Cost Inquiry,.twbx,Operations - Houston-Ref,Houston-Ref,/thorpespecialtyservicescorporation/projects/113339/workbooks,2018-08-30 12:50:29,
12+
Job Cost Inquiry,.twbx,Operations - International,International,/thorpespecialtyservicescorporation/projects/113340/workbooks,2018-08-30 12:50:51,
13+
Job Cost Inquiry,.twbx,Operations - JT-Beaumont,JT-Beaumont,/thorpespecialtyservicescorporation/projects/113356/workbooks,2018-08-30 12:51:11,
14+
Job Cost Inquiry,.twbx,Operations - JT-Houston,JT-Houston,/thorpespecialtyservicescorporation/projects/113341/workbooks,2018-08-30 12:51:35,
15+
Job Cost Inquiry,.twbx,Operations - St. Gabriel-Cor,St. Gabriel-Cor,/thorpespecialtyservicescorporation/projects/113342/workbooks,2018-08-30 12:51:59,
16+
Job Cost Inquiry,.twbx,Operations - St. Gabriel-Ref,St. Gabriel-Ref,/thorpespecialtyservicescorporation/projects/113343/workbooks,2018-08-30 12:52:24,
17+
Job Cost Inquiry,.twbx,Operations - Tulsa,Tulsa,/thorpespecialtyservicescorporation/projects/113344/workbooks,2018-08-30 12:52:46,

samples/filter-and-replicate/filter-and-replicate.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import platform
1515
import datetime
1616
import time
17+
import sys
18+
import shutil
1719

1820
############################################################
1921
# Step 3) Use a database list (in CSV), loop thru and
@@ -37,14 +39,16 @@ def main():
3739
parser = argparse.ArgumentParser(description='Publish a workbook to server.')
3840
parser.add_argument('--server', '-s', required=True, help='server address')
3941
parser.add_argument('--username', '-u', required=True, help='username to sign into server')
40-
parser.add_argument('--sitename','-sn',required=True, help='site name to sign into')
42+
parser.add_argument('--sitename','-sn', required=True, help='site name to sign into')
43+
parser.add_argument('--password', '-p', required=True, help='Publishing Password')
4144
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
4245
help='desired logging level (set to error by default)')
4346
parser.add_argument('--as-job', '-a', help='Publishing asynchronously', action='store_true')
47+
4448

4549
args = parser.parse_args()
4650

47-
password = getpass.getpass("Password: ")
51+
password = args.password
4852

4953

5054
# Set logging level based on user input, or error by default
@@ -62,7 +66,7 @@ def main():
6266
zip = "Zip"
6367
export = "Export"
6468
columns = ['Workbook', 'Format', 'Project', 'Branch', 'Directory', 'PublishDate','ModifiedDate' ]
65-
69+
oldworkbookname = ""
6670
with server.auth.sign_in(tableau_auth):
6771
with open('databases.csv',mode='r') as csvfile:
6872
total = sum(1 for line in open('databases.csv'))
@@ -73,6 +77,12 @@ def main():
7377
writer.writeheader()
7478
for row in databases:
7579
if any(row):
80+
if(row['Workbook'] != oldworkbookname):
81+
shutil.rmtree('Export', ignore_errors=True, onerror=None)
82+
os.makedirs('Export')
83+
shutil.rmtree('Zip', ignore_errors=True, onerror=None)
84+
os.makedirs('Zip')
85+
7686
print ("working on item: "+ str(count)+" \n")
7787
mtime = parse(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(os.path.getmtime(os.path.join(source, row['Workbook'] + ".twbx")))))
7888
ptime = parse(row['PublishDate'])
@@ -90,7 +100,7 @@ def main():
90100
# Update the filters
91101
for children in datasource._datasourceXML._children:
92102
if "column" in children.attrib and "class" in children.attrib:
93-
if children.attrib["column"] == "[Branch]" and children.attrib["class"] == "categorical":
103+
if "Branch" in children.attrib["column"] and children.attrib["class"] == "categorical":
94104
for subchildren in children._children:
95105
if "member" in subchildren.attrib:
96106
subchildren.attrib["member"] = '"' + row['Branch'] + '"'
@@ -100,14 +110,14 @@ def main():
100110
outputpath = os.path.join(export, row['Workbook'] + ' - ' + row['Branch'] + ".twb")
101111
sourceWB.save_as(outputpath)
102112

103-
if(row['Format'] == ".twbx"):
104-
z = zipfile.ZipFile(os.path.join(export, row['Workbook'] + ' - ' + row['Branch'] + row['Format']),mode='w',compression=zipfile.ZIP_DEFLATED)
105-
z.write(os.path.join(export, row['Workbook'] + ' - ' + row['Branch'] + ".twb"),item.replace("Export",""))
106-
for item in list_files(zip):
107-
if item.endswith(".twb") != True:
108-
z.write(item,item.replace("Zip",""))
109-
110-
z.close()
113+
z = zipfile.ZipFile(os.path.join(export, row['Workbook'] + ' - ' + row['Branch'] + row['Format']),mode='w',compression=zipfile.ZIP_DEFLATED)
114+
z.write(os.path.join(export, row['Workbook'] + ' - ' + row['Branch'] + ".twb"),item.replace("Export",""))
115+
for item in list_files(zip):
116+
if item.endswith(".twb") != True:
117+
z.write(item,item.replace("Zip",""))
118+
119+
z.close()
120+
111121

112122
elif (row['Format'] ==".twb"):
113123
sourceWB = Workbook(os.path.join(source, row['Workbook'] + ".twb"))
@@ -123,7 +133,7 @@ def main():
123133
# Save our newly created workbook with the new file name
124134
outputpath = os.path.join(export, row['Workbook'] + ' - ' + row['Branch'] + ".twb")
125135
sourceWB.save_as(outputpath)
126-
136+
oldworkbookname = row['Workbook']
127137

128138
all_projects, pagination_item = server.projects.get()
129139
default_project = next((project for project in all_projects if project.name == row['Project']), None)

samples/filter-and-replicate/filter-and-replicate.pyproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<SchemaVersion>2.0</SchemaVersion>
66
<ProjectGuid>{e9772cb6-1e47-4d77-9065-9e6995218d0c}</ProjectGuid>
77
<ProjectHome />
8-
<StartupFile>filter-and-replicate.py</StartupFile>
8+
<StartupFile>test.py</StartupFile>
99
<SearchPath />
1010
<WorkingDirectory>.</WorkingDirectory>
1111
<OutputPath>.</OutputPath>
@@ -20,6 +20,9 @@
2020
</PropertyGroup>
2121
<ItemGroup>
2222
<Compile Include="filter-and-replicate.py" />
23+
<Compile Include="test.py">
24+
<SubType>Code</SubType>
25+
</Compile>
2326
</ItemGroup>
2427
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
2528
</Project>

0 commit comments

Comments
 (0)
0