Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/adblockplus/files/log/import.py

Issue 29341151: Issue 4019 - Added "Edge" to platform choices in Issues tracker at issues1. (Closed)
Patch Set: Created May 10, 2016, 3:35 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « modules/adblockplus/files/development_host_rsa_key.pub ('k') | modules/adblockplus/files/sudoers/puppet » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/adblockplus/files/log/import.py
===================================================================
new file mode 100644
--- /dev/null
+++ b/modules/adblockplus/files/log/import.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*- ------------------------------------------------
+# vi:set fenc=utf-8 ft=python ts=8 et sw=4 sts=4:
+
+__doc__ = """ Redirect STDIN into an ABP log channel.
+
+"""
+import argparse
+import fcntl
+import os
+import shutil
+import sys
+
+try:
+ parser = argparse.ArgumentParser(allow_abbrev=False, description=__doc__)
+except TypeError:
+ parser = argparse.ArgumentParser(description=__doc__)
+
+parser.add_argument(
+ 'name',
+ help='The base name of the logfile to import',
+ metavar='LOG',
+ type=str,
+)
+
+parser.add_argument(
+ '-s', '--source',
+ help='The name (recommended) or IP of the source host',
+ metavar='HOSTNAME',
+ type=str,
+)
+
+parser.add_argument(
+ '-t', '--target',
+ help='The location of the upload/import directory',
+ metavar='DIRECTORY',
+ type=str,
+)
+
+arguments = parser.parse_args()
+destination = os.path.join(arguments.target, arguments.source, arguments.name)
+output = open(destination, 'a')
+fcntl.flock(output, fcntl.F_WRLCK | fcntl.F_EXLCK)
+
+try:
+ shutil.copyfileobj(sys.stdin, output)
+finally:
+ fcntl.flock(output, fcntl.F_UNLCK)
+
+output.close()
« no previous file with comments | « modules/adblockplus/files/development_host_rsa_key.pub ('k') | modules/adblockplus/files/sudoers/puppet » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld