comparison collect_issues.py @ 2:3e9f4a6803d1

replaced funtion with string.isdigit.
author sean
date Wed, 15 Apr 2015 11:40:28 +0200
parents 2df45f6ecd81
children e95f7bee8643
comparison
equal deleted inserted replaced
1:2df45f6ecd81 2:3e9f4a6803d1
23 ("__login_password", "demo"), 23 ("__login_password", "demo"),
24 ("@action", "Login"), 24 ("@action", "Login"),
25 ) 25 )
26 26
27 save_stats_in_db(LOGIN_PARAMETERS_DEMO, BASE_URL_DEMO, rcd.DATABASE_DEMO, rcd.COLUMNS, rcd.CREATE_DB, rcd.INSERT_NEW, SEARCH_URL_DEMO) 27 save_stats_in_db(LOGIN_PARAMETERS_DEMO, BASE_URL_DEMO, rcd.DATABASE_DEMO, rcd.COLUMNS, rcd.CREATE_DB, rcd.INSERT_NEW, SEARCH_URL_DEMO)
28
29 """ 28 """
30 29
31 import http.cookiejar 30 import http.cookiejar
32 import urllib.parse 31 import urllib.parse
33 import urllib.request 32 import urllib.request
39 38
40 39
41 CHECK_ROUNDUP_ORDER = "priority?@action=export_csv&@columns=id,order" 40 CHECK_ROUNDUP_ORDER = "priority?@action=export_csv&@columns=id,order"
42 CHECK_ROUNDUP_SEARCH_VALUES = "status?@action=export_csv&@columns=id&@filter=open&open=1" 41 CHECK_ROUNDUP_SEARCH_VALUES = "status?@action=export_csv&@columns=id&@filter=open&open=1"
43 SEARCH_ROUNDUP = "issue?@action=export_csv&@columns=priority&@filter=status&@pagesize=500&@startwith=0&status=-1,{search_values}" 42 SEARCH_ROUNDUP = "issue?@action=export_csv&@columns=priority&@filter=status&@pagesize=500&@startwith=0&status=-1,{search_values}"
44
45
46
47
48 43
49 44
50 def connect_to_server(params, baseurl): 45 def connect_to_server(params, baseurl):
51 enc_data = urllib.parse.urlencode(params).encode() 46 enc_data = urllib.parse.urlencode(params).encode()
52 cj = http.cookiejar.CookieJar() 47 cj = http.cookiejar.CookieJar()
94 cur.close() 89 cur.close()
95 if con: 90 if con:
96 con.close() 91 con.close()
97 92
98 93
99 def represents_int(s):
100 try:
101 int(s)
102 return True
103 except ValueError:
104 return False
105
106
107 def issues_to_quantities(issue_csv, columns, orders_csv): 94 def issues_to_quantities(issue_csv, columns, orders_csv):
108 95
109 quantities = [0] * len(columns) 96 quantities = [0] * len(columns)
110 order_dict = {} 97 order_dict = {}
111 98
114 order_dict[row["id"]] = int(float(row["order"])) # int(float()) because the order-value is indeed "1.0, 2.0" etc 101 order_dict[row["id"]] = int(float(row["order"])) # int(float()) because the order-value is indeed "1.0, 2.0" etc
115 102
116 for issue in issue_csv: 103 for issue in issue_csv:
117 priority = issue["priority"] 104 priority = issue["priority"]
118 105
119 if represents_int(priority) == True : 106 if priority.isdigit() == True :
120 quantities[order_dict[priority] -1 ] += 1 107 quantities[order_dict[priority] -1 ] += 1
121 108
122 # print("quantities : " + str(quantities)) 109 # print("quantities : " + str(quantities))
123 110
124 return quantities 111 return quantities
163 150
164 opener.close() 151 opener.close()
165 152
166 quantities = issues_to_quantities(current_issues_csv, columns, order_csv) 153 quantities = issues_to_quantities(current_issues_csv, columns, order_csv)
167 154
168 save_issues_to_db(quantities, db_file, sql_create_db, sql_insert_in_db) 155 # save_issues_to_db(quantities, db_file, sql_create_db, sql_insert_in_db)
169 156
170 except urllib.error.URLError as e: 157 except urllib.error.URLError as e:
171 print("No Valid Connection to server : " + baseurl + "\nerror: " + str(e)) 158 print("No Valid Connection to server : " + baseurl + "\nerror: " + str(e))
172 159
173 160
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)