rda-python-metrics 1.0.21__tar.gz → 1.0.23__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rda-python-metrics might be problematic. Click here for more details.

Files changed (59) hide show
  1. {rda_python_metrics-1.0.21/src/rda_python_metrics.egg-info → rda_python_metrics-1.0.23}/PKG-INFO +1 -1
  2. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/pyproject.toml +2 -2
  3. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillipinfo.py +47 -39
  4. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillipinfo.usg +3 -1
  5. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23/src/rda_python_metrics.egg-info}/PKG-INFO +1 -1
  6. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/LICENSE +0 -0
  7. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/MANIFEST.in +0 -0
  8. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/README.md +0 -0
  9. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/setup.cfg +0 -0
  10. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/PgIPInfo.py +0 -0
  11. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/PgView.py +0 -0
  12. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/__init__.py +0 -0
  13. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillawsusage.py +0 -0
  14. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillawsusage.usg +0 -0
  15. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillcdgusage.py +0 -0
  16. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillcdgusage.usg +0 -0
  17. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillcodusage.py +0 -0
  18. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillcodusage.usg +0 -0
  19. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillcountry.py +0 -0
  20. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillendtime.py +0 -0
  21. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillglobususage.py +0 -0
  22. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillglobususage.usg +0 -0
  23. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/filloneorder.py +0 -0
  24. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/filloneorder.usg +0 -0
  25. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillosdfusage.py +0 -0
  26. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillosdfusage.usg +0 -0
  27. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillrdadb.py +0 -0
  28. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/fillrdadb.usg +0 -0
  29. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/filltdsusage.py +0 -0
  30. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/filltdsusage.usg +0 -0
  31. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/filluser.py +0 -0
  32. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/filluser.usg +0 -0
  33. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/logarch.py +0 -0
  34. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/logarch.usg +0 -0
  35. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/pgperson.py +0 -0
  36. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/pgsyspath.py +0 -0
  37. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/pgusername.py +0 -0
  38. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewallusage.py +0 -0
  39. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewallusage.usg +0 -0
  40. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewcheckusage.py +0 -0
  41. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewcheckusage.usg +0 -0
  42. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewcodusage.py +0 -0
  43. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewcodusage.usg +0 -0
  44. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewordusage.py +0 -0
  45. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewordusage.usg +0 -0
  46. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewrqstusage.py +0 -0
  47. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewrqstusage.usg +0 -0
  48. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewtdsusage.py +0 -0
  49. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewtdsusage.usg +0 -0
  50. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewwebfile.py +0 -0
  51. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewwebfile.usg +0 -0
  52. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewwebusage.py +0 -0
  53. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics/viewwebusage.usg +0 -0
  54. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics.egg-info/SOURCES.txt +0 -0
  55. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics.egg-info/dependency_links.txt +0 -0
  56. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics.egg-info/entry_points.txt +0 -0
  57. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics.egg-info/requires.txt +0 -0
  58. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/src/rda_python_metrics.egg-info/top_level.txt +0 -0
  59. {rda_python_metrics-1.0.21 → rda_python_metrics-1.0.23}/tests/test_metrics.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_metrics
3
- Version: 1.0.21
3
+ Version: 1.0.23
4
4
  Summary: RDA Python Package to gather and view data usage metrics
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-metrics
@@ -6,9 +6,9 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "rda_python_metrics"
9
- version = "1.0.21"
9
+ version = "1.0.23"
10
10
  authors = [
11
- { name="Zaihua Ji", email="zji@ucar.edu" },
11
+ { name="Zaihua Ji", email="zji@ucar.edu" },
12
12
  ]
13
13
  description = "RDA Python Package to gather and view data usage metrics"
14
14
  readme = "README.md"
@@ -25,10 +25,11 @@ from rda_python_common import PgDBI
25
25
  from . import PgIPInfo
26
26
 
27
27
  # the define options for gathering ipinfo data
28
+ DATES = 0x01 # fix data usages for given dates
28
29
  MONTH = 0x02 # fix data usages for given months
29
30
  YEARS = 0x04 # fix data usages for given years
30
31
  NDAYS = 0x08 # fix data usages in recent number of days
31
- MULTI = (MONTH|YEARS)
32
+ MULTI = (DATES|MONTH|YEARS)
32
33
  SINGL = (NDAYS)
33
34
 
34
35
  IPINFO = {
@@ -49,8 +50,10 @@ def main():
49
50
  for arg in argv:
50
51
  if arg == "-b":
51
52
  PgLOG.PGLOG['BCKGRND'] = 1
52
- elif re.match(r'^-[mNy]$', arg) and option == 0:
53
- if arg == "-m":
53
+ elif re.match(r'^-[dmNy]$', arg) and option == 0:
54
+ if arg == "-d":
55
+ option = DATES
56
+ elif arg == "-m":
54
57
  option = MONTH
55
58
  elif arg == "-y":
56
59
  option = YEARS
@@ -74,17 +77,6 @@ def main():
74
77
  PgDBI.dssdb_dbname()
75
78
  PgLOG.cmdlog("fillipinfo {}".format(' '.join(argv)))
76
79
 
77
- if option&NDAYS:
78
- curdate = IPINFO['CDATE']
79
- datelimit = PgUtil.adddate(curdate, 0, 0, -int(inputs[0]))
80
- option = MONTH
81
- inputs = []
82
-
83
- while curdate >= datelimit:
84
- tms = curdate.split('-')
85
- inputs.append("{}-{}".format(tms[0], tms[1]))
86
- curdate = PgUtil.adddate(curdate, 0, 0, -int(tms[2]))
87
-
88
80
  fill_ip_info(option, inputs, table)
89
81
 
90
82
  sys.exit(0)
@@ -95,32 +87,48 @@ def main():
95
87
  def fill_ip_info(option, inputs, table):
96
88
 
97
89
  cntall = 0
98
- date = None
90
+ func = eval('fix_{}_records'.format(table))
99
91
  for input in inputs:
100
92
  if option&NDAYS:
101
93
  edate = IPINFO['CDATE']
102
- date = PgUtil.adddate(edate, 0, 0, -int(input))
94
+ date = PgUtil.adddate(edate, 0, 0, -int(input))
95
+ elif option&DATES:
96
+ edate = date = input
103
97
  elif option&MONTH:
104
98
  tms = input.split('-')
105
99
  date = "{}-{:02}-01".format(tms[0], int(tms[1]))
106
100
  edate = PgUtil.enddate(date, 0, 'M')
107
- elif option&YEARS:
101
+ else:
108
102
  date = input + "-01-01"
109
103
  edate = input + "-12-31"
110
-
111
104
  while date <= edate:
112
- func = eval('fix_{}_records'.format(table))
113
- cntall += func(date)
114
- date = PgUtil.adddate(date, 0, 0, 1)
115
- return cntall
105
+ (ndate, cond) = get_next_date(date, edate)
106
+ cntall += func(date, cond)
107
+ date = PgUtil.adddate(ndate, 0, 0, 1)
108
+
109
+ if cntall > 2:
110
+ PgLOG.pglog("{}: Total {} records updated".format(table, cntall), PgLOG.LOGWRN)
111
+
112
+ def get_next_date(date, edate):
113
+
114
+ if date < edate:
115
+ ndate = PgUtil.enddate(date, 'M')
116
+ if ndate > edate: ndate = edate
117
+ if date < ndate:
118
+ cond = f"BETWEEN '{date}' AND '{ndate}'"
119
+ else:
120
+ cond = f"= '{date}'"
121
+
122
+ return (ndate, cond)
123
+
116
124
 
117
- def fix_allusage_records(date):
125
+ def fix_allusage_records(date, cnd):
118
126
 
119
127
  cnt = 0
120
128
  ms = re.match(r'^(\d+)-', date)
121
129
  year = ms.group(1)
122
130
  table = 'allusage_' + year
123
- cond = "date = '{}' AND region IS NULL".format(date)
131
+ cond = f"date {cnd} AND region IS NULL"
124
132
  pgrecs = PgDBI.pgmget(table, 'aidx, email, ip', cond, PgLOG.LGEREX)
125
133
  if not pgrecs: return 0
126
134
  cnt = len(pgrecs['ip']) if pgrecs else 0
@@ -131,15 +139,15 @@ def fix_allusage_records(date):
131
139
  mcnt += PgDBI.pgupdt(table, record, "aidx = '{}'".format(pgrecs['aidx'][i]))
132
140
 
133
141
  s = 's' if cnt > 1 else ''
134
- PgLOG.pglog("{}: {} of {} record{} updated for {}".format(table, mcnt, cnt, s, date), PgLOG.LOGWRN)
142
+ PgLOG.pglog(f"{table}: {mcnt} of {cnt} record{s} updated for date {cnd}", PgLOG.LOGWRN)
135
143
 
136
144
  return mcnt
137
145
 
138
- def fix_tdsusage_records(date):
146
+ def fix_tdsusage_records(date, cnd):
139
147
 
140
148
  table = 'tdsusage'
141
- cond = "date = '{}' AND region IS NULL".format(date)
142
- pgrecs = PgDBI.pgmget(table, 'time, email, ip', cond, PgLOG.LGEREX)
149
+ cond = f"date {cnd} AND region IS NULL"
150
+ pgrecs = PgDBI.pgmget(table, 'date, time, email, ip', cond, PgLOG.LGEREX)
143
151
  if not pgrecs: return 0
144
152
  cnt = len(pgrecs['ip']) if pgrecs else 0
145
153
  mcnt = 0
@@ -147,18 +155,18 @@ def fix_tdsusage_records(date):
147
155
  ip = pgrecs['ip'][i]
148
156
  record = PgIPInfo.get_missing_ipinfo(ip, pgrecs['email'][i])
149
157
  if record:
150
- cond = "date = '{}' AND time = '{}' AND ip = '{}'".format(date, pgrecs['time'][i], ip)
158
+ cond = "date = '{}' AND time = '{}' AND ip = '{}'".format(pgrecs['date'][i], pgrecs['time'][i], ip)
151
159
  mcnt += PgDBI.pgupdt(table, record, cond)
152
160
 
153
161
  s = 's' if cnt > 1 else ''
154
- PgLOG.pglog("{}: {} of {} record{} updated for {}".format(table, mcnt, cnt, s, date), PgLOG.LOGWRN)
162
+ PgLOG.pglog(f"{table}: {mcnt} of {cnt} record{s} updated for date {cnd}", PgLOG.LOGWRN)
155
163
 
156
164
  return mcnt
157
165
 
158
- def fix_codusage_records(date):
166
+ def fix_codusage_records(date, cnd):
159
167
 
160
168
  table = 'codusage'
161
- cond = "date = '{}' AND region IS NULL".format(date)
169
+ cond = f"date {cnd} AND region IS NULL"
162
170
  pgrecs = PgDBI.pgmget(table, 'codidx, email, ip', cond, PgLOG.LGEREX)
163
171
  if not pgrecs: return 0
164
172
  cnt = len(pgrecs['ip']) if pgrecs else 0
@@ -169,14 +177,14 @@ def fix_codusage_records(date):
169
177
  mcnt += PgDBI.pgupdt(table, record, "codidx = '{}'".format(pgrecs['codidx'][i]))
170
178
 
171
179
  s = 's' if cnt > 1 else ''
172
- PgLOG.pglog("{}: {} of {} record{} updated for {}".format(table, mcnt, cnt, s, date), PgLOG.LOGWRN)
180
+ PgLOG.pglog(f"{table}: {mcnt} of {cnt} record{s} updated for date {cnd}", PgLOG.LOGWRN)
173
181
 
174
182
  return mcnt
175
183
 
176
- def fix_wuser_records(date):
184
+ def fix_wuser_records(date, cnd):
177
185
 
178
186
  table = 'wuser'
179
- cond = "start_date = '{}' AND region IS NULL".format(date)
187
+ cond = f"start_date {cnd} AND region IS NULL"
180
188
  pgrecs = PgDBI.pgmget(table, 'wuid, email, ip', cond, PgLOG.LGEREX)
181
189
  if not pgrecs: return 0
182
190
  cnt = len(pgrecs['ip']) if pgrecs else 0
@@ -189,14 +197,14 @@ def fix_wuser_records(date):
189
197
  mcnt += PgDBI.pgupdt(table, record, "wuid = '{}'".format(pgrecs['wuid'][i]))
190
198
 
191
199
  s = 's' if cnt > 1 else ''
192
- PgLOG.pglog("{}: {} of {} record{} updated for {}".format(table, mcnt, cnt, s, date), PgLOG.LOGWRN)
200
+ PgLOG.pglog(f"{table}: {mcnt} of {cnt} record{s} updated for start_date {cnd}", PgLOG.LOGWRN)
193
201
 
194
202
  return mcnt
195
203
 
196
- def fix_ipinfo_records(date):
204
+ def fix_ipinfo_records(date, cnd):
197
205
 
198
206
  table = 'ipinfo'
199
- cond = "adddate = '{}' AND region IS NULL".format(date)
207
+ cond = f"adddate {cnd} AND region IS NULL"
200
208
  pgrecs = PgDBI.pgmget(table, 'ip', cond, PgLOG.LGEREX)
201
209
  if not pgrecs: return 0
202
210
  cnt = len(pgrecs['ip']) if pgrecs else 0
@@ -205,7 +213,7 @@ def fix_ipinfo_records(date):
205
213
  if PgIPInfo.set_ipinfo(pgrecs['ip'][i]): mcnt +=1
206
214
 
207
215
  s = 's' if cnt > 1 else ''
208
- PgLOG.pglog("{}: {} of {} record{} updated".format(table, mcnt, cnt, s), PgLOG.LOGWRN)
216
+ PgLOG.pglog(f"{table}: {mcnt} of {cnt} record{s} updated for adddate {cnd}", PgLOG.LOGWRN)
209
217
 
210
218
  return mcnt
211
219
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  Usage: fillipinfo [-b] -t TableName [-N NumberDay] [-m YearMonths] [-y Years]
5
5
 
6
- select option, -t and -m, -N or -y to run this application.
6
+ select option, -t and -d, -m, -N or -y to run this application.
7
7
 
8
8
  - Option -b, log process information into logfile only;
9
9
 
@@ -13,6 +13,8 @@
13
13
 
14
14
  - Option -N, fix usage info in recent NumberDay days;
15
15
 
16
+ - Option -d, fix usage info in given dates;
17
+
16
18
  - Option -m, fix usage info in given months;
17
19
 
18
20
  - Option -y, fix usage info in given years.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_metrics
3
- Version: 1.0.21
3
+ Version: 1.0.23
4
4
  Summary: RDA Python Package to gather and view data usage metrics
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-metrics