XZise has uploaded a new change for review. https://gerrit.wikimedia.org/r/161227
Change subject: [FIX] Close csv file and subprocess stdout streams ...................................................................... [FIX] Close csv file and subprocess stdout streams Bug: 70969 Change-Id: I839ef18cd40758fb331a85e615b39063e95f9915 --- M pywikibot/version.py M scripts/data_ingestion.py 2 files changed, 19 insertions(+), 16 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/27/161227/1 diff --git a/pywikibot/version.py b/pywikibot/version.py index c8cb36c..994f387 100644 --- a/pywikibot/version.py +++ b/pywikibot/version.py @@ -204,19 +204,21 @@ tag = tag[(s + 6):e] t = tag.strip().split('/') tag = '[%s] %s' % (t[0][:-1], '-'.join(t[3:])) - info = subprocess.Popen([cmd, '--no-pager', - 'log', '-1', - '--pretty=format:"%ad|%an|%h|%H|%d"' - '--abbrev-commit', - '--date=iso'], - cwd=_program_dir, - stdout=subprocess.PIPE).stdout.read() + with subprocess.Popen([cmd, '--no-pager', + 'log', '-1', + '--pretty=format:"%ad|%an|%h|%H|%d"' + '--abbrev-commit', + '--date=iso'], + cwd=_program_dir, + stdout=subprocess.PIPE).stdout as stdout: + info = stdout.read() info = info.decode(config.console_encoding).split('|') date = info[0][:-6] date = time.strptime(date.strip('"'), '%Y-%m-%d %H:%M:%S') - rev = subprocess.Popen([cmd, 'rev-list', 'HEAD'], - cwd=_program_dir, - stdout=subprocess.PIPE).stdout.read() + with subprocess.Popen([cmd, 'rev-list', 'HEAD'], + cwd=_program_dir, + stdout=subprocess.PIPE).stdout as stdout: + rev = stdout.read() rev = 'g%s' % len(rev.splitlines()) hsh = info[3] # also stored in '.git/refs/heads/master' if (not date or not tag or not rev) and not path: diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py index 70856eb..a832745 100755 --- a/scripts/data_ingestion.py +++ b/scripts/data_ingestion.py @@ -146,12 +146,13 @@ self._doUpload(photo) if __name__ == "__main__": - reader = CSVReader(open('tests/data/csv_ingestion.csv'), 'url') - bot = DataIngestionBot( - reader, - "%(name)s - %(set)s.%(_ext)s", ":user:valhallasw/test_template", - pywikibot.Site('test', 'test')) - bot.run() + with open('tests/data/csv_ingestion.csv') as f: + reader = CSVReader(f, 'url') + bot = DataIngestionBot( + reader, + "%(name)s - %(set)s.%(_ext)s", ":user:valhallasw/test_template", + pywikibot.Site('test', 'test')) + bot.run() ''' class DataIngestionBot: -- To view, visit https://gerrit.wikimedia.org/r/161227 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I839ef18cd40758fb331a85e615b39063e95f9915 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: XZise <commodorefabia...@gmx.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits