Yurik has submitted this change and it was merged.
Change subject: minor - smslog reporting, cleanup
......................................................................
minor - smslog reporting, cleanup
Change-Id: I8a87f6fe2afc1a8fbc0ad8317e9f63b28c9e08c1
---
M .gitignore
D scripts/run.cmd
M scripts/smslogs.py
3 files changed, 18 insertions(+), 12 deletions(-)
Approvals:
Yurik: Verified; Looks good to me, approved
diff --git a/.gitignore b/.gitignore
index 85b3783..3afb035 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@
/logs
/scripts/settings
__pycache__
+/scripts/build
diff --git a/scripts/run.cmd b/scripts/run.cmd
deleted file mode 100644
index 9d46628..0000000
--- a/scripts/run.cmd
+++ /dev/null
@@ -1,2 +0,0 @@
-c:\Python27\python.exe download.py
-pause
diff --git a/scripts/smslogs.py b/scripts/smslogs.py
index 0b42ee2..48885f3 100644
--- a/scripts/smslogs.py
+++ b/scripts/smslogs.py
@@ -119,25 +119,32 @@
fileDate = self.getFileDate(filename)
fileExists = os.path.exists(filePath)
+ skipReason = False
+ dlReason = False
if key.size == 0:
- safePrint(u'Skipping empty file %s' % filename)
- continue
+ skipReason = u'Skipping empty file %s' % filename
elif not fileExists:
- reason = u"it doesn't exist"
+ dlReason = u'Downloading new file %s' % filename
elif key.size != os.stat(filePath).st_size:
- reason = u'local size %s <> remote %s' % (
+ dlReason = u'The local size {0:s} <> remote {1:s} for file
{2:s}'.format(
locale.format(u"%d", os.stat(filePath).st_size,
grouping=True),
- locale.format(u"%d", key.size, grouping=True))
+ locale.format(u"%d", key.size, grouping=True),
+ filename)
elif fileDate and self.downloadIfAfter and fileDate >
self.downloadIfAfter:
- reason = u'date is too close to last file date %s' %
self.downloadIfAfter
+ dlReason = u'Re-downloading {0:s} since its date is too close
to last file date {1:s}'\
+ .format(filename, self.downloadIfAfter)
else:
- continue
+ skipReason = True
if not self.settings.enableDownloadOld and not fileDate:
- safePrint(u'Skipping legacy-named file %s even though %s' %
(filename, reason))
+ safePrint(u'Skipping legacy-named file %s even though %s' %
(filename, dlReason))
+ continue
+ if skipReason:
+ if isinstance(skipReason, basestring):
+ safePrint(skipReason)
continue
- safePrint(u'Downloading %s because %s' % (filename, reason))
+ safePrint(dlReason)
if fileExists:
if os.stat(filePath).st_size == 0:
safePrint(u'Removing empty file %s' % filePath)
@@ -198,7 +205,7 @@
writeLine(dst, last)
last = False
elif isinstance(last, basestring):
- last = last + '\t' + l
+ last = last + u'\t' + l
writeLine(dst, last)
if fileDate and (not self.settings.lastProcessedTs or
self.settings.lastProcessedTs < fileDate):
--
To view, visit https://gerrit.wikimedia.org/r/154233
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8a87f6fe2afc1a8fbc0ad8317e9f63b28c9e08c1
Gerrit-PatchSet: 1
Gerrit-Project: analytics/zero-sms
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits