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

Side by Side Diff: modules/adblockplus/files/log/import.py

Issue 29338680: Issue 3825 - Replace Logstash setup with Fluentd (Closed)
Patch Set: Created March 18, 2016, 6:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | modules/adblockplus/manifests/log.pp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*- ------------------------------------------------
3 # vi:set fenc=utf-8 ft=python ts=8 et sw=4 sts=4:
4
5 __doc__ = """ Redirect STDIN into an ABP log channel.
6
7 """
8 import argparse
9 import fcntl
10 import os
11 import shutil
12 import sys
13
14 try:
15 parser = argparse.ArgumentParser(allow_abbrev=False, description=__doc__)
16 except TypeError:
17 parser = argparse.ArgumentParser(description=__doc__)
18
19 parser.add_argument(
20 'name',
21 help='The base name of the logfile to import',
22 metavar='LOG',
23 type=str,
24 )
25
26 parser.add_argument(
27 '-s', '--source',
28 help='The name (recommended) or IP of the source host',
29 metavar='HOSTNAME',
30 type=str,
31 )
32
33 parser.add_argument(
34 '-t', '--target',
35 help='The location of the upload/import directory',
36 metavar='DIRECTORY',
37 type=str,
38 )
39
40 arguments = parser.parse_args()
41 destination = os.path.join(arguments.target, arguments.source, arguments.name)
42 output = open(destination, 'a')
43 fcntl.flock(output, fcntl.F_WRLCK | fcntl.F_EXLCK)
44
45 try:
46 shutil.copyfileobj(sys.stdin, output)
47 finally:
48 fcntl.flock(output, fcntl.F_UNLCK)
49
50 output.close()
OLDNEW
« no previous file with comments | « no previous file | modules/adblockplus/manifests/log.pp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld