commit d7ce38ced2811952bd0c716c2d2bf35ab2a6c7d5
parent 8ed02236c38415526b755eedfa8d32fb0a3779af
Author: parazyd <parazyd@dyne.org>
Date: Sun, 11 Mar 2018 20:16:08 +0100
pylint on rpsync.
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/bin/rpsync b/bin/rpsync
@@ -1,6 +1,9 @@
#!/usr/bin/env python3
+#
# Copy me if you can
# by parazyd
+#
+""" rp module for syncing from a remote IMAP server. """
from os import getenv
from os.path import join
@@ -16,12 +19,14 @@ if not PROFILE:
def usage():
+ """ usage function """
print(" * usage: %s [-n]" % argv[0])
print("\t-n: dry run")
exit(1)
def parsecfg():
+ """ function for parsing the config file """
cfgmap = {}
rawtxt = open(join(PROFILE, 'config')).read()
contents = rawtxt.split('\n')[:-1]
@@ -33,11 +38,13 @@ def parsecfg():
def main():
+ """ main routine """
if len(argv) > 1 and argv[1] != '-n':
usage()
dryrun = False
- if '-n' in argv: dryrun = True
+ if '-n' in argv:
+ dryrun = True
config = parsecfg()
ntype = config['rnet'].split('!')[0]
@@ -55,7 +62,8 @@ def main():
imap = IMAP4(host=rhost, port=rport)
print(" * connecting to %s:%s" % (rhost, rport))
- if dryrun: print(" * dry run enabled")
+ if dryrun:
+ print(" * dry run enabled")
data = imap.login(config['ruser'], config['rpass'])
data = imap.list()
@@ -80,9 +88,9 @@ def main():
for j in data[1]:
email = imap.fetch(j.split()[0], 'body[]')
emailtopipe = email[1][0][1]
- mb = i.replace(b'.', b'/')
+ mbx = i.replace(b'.', b'/')
- proc = Popen(['/usr/libexec/dovecot/deliver', '-m', mb],
+ proc = Popen(['/usr/libexec/dovecot/deliver', '-m', mbx],
stdin=PIPE)
proc.stdin.write(emailtopipe)
proc.communicate()