Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
fbd75d09
Commit
fbd75d09
authored
Nov 13, 2015
by
Enrico Zini
Browse files
Deal with byte streams, and what on earth was happening with those copyfileobj?
parent
ae2b19b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
archive-process-email
View file @
fbd75d09
...
...
@@ -51,7 +51,7 @@ class umask_override(object):
class
Dispatcher
(
object
):
re_dest
=
re
.
compile
(
"^archive-(.+)@nm.debian.org$"
)
def
__init__
(
self
,
infd
=
sys
.
stdin
,
destdir
=
DEFAULT_DESTDIR
):
def
__init__
(
self
,
infd
,
destdir
=
DEFAULT_DESTDIR
):
self
.
destdir
=
destdir
self
.
infd
=
infd
self
.
_db
=
None
...
...
@@ -114,15 +114,17 @@ class Dispatcher(object):
self
.
msg
[
"NM-Archive-Failsafe-Reason"
]
=
reason
with
umask_override
(
0o037
)
as
uo
:
with
open
(
os
.
path
.
join
(
self
.
destdir
,
"failsafe.mbox"
),
"a"
)
as
out
:
print
(
self
.
msg
.
as_string
(
True
),
file
=
out
)
shutil
.
copyfileobj
(
sys
.
stdin
,
self
.
infd
)
with
open
(
os
.
path
.
join
(
self
.
destdir
,
"failsafe.mbox"
),
"ab"
)
as
out
:
out
.
write
(
self
.
msg
.
as_string
(
True
).
encode
(
"utf-8"
))
out
.
write
(
b
"
\n
"
)
shutil
.
copyfileobj
(
self
.
infd
,
out
)
def
deliver_to_archive_key
(
self
,
arc_key
):
with
umask_override
(
0o037
)
as
uo
:
with
open
(
os
.
path
.
join
(
self
.
destdir
,
"%s.mbox"
%
arc_key
),
"a"
)
as
out
:
print
(
self
.
msg
.
as_string
(
True
),
file
=
out
)
shutil
.
copyfileobj
(
sys
.
stdin
,
self
.
infd
)
with
open
(
os
.
path
.
join
(
self
.
destdir
,
"%s.mbox"
%
arc_key
),
"ab"
)
as
out
:
out
.
write
(
self
.
msg
.
as_string
(
True
).
encode
(
"utf-8"
))
out
.
write
(
b
"
\n
"
)
shutil
.
copyfileobj
(
self
.
infd
,
out
)
def
archive_key_from_dest_key
(
self
,
dest_key
):
cur
=
self
.
db
.
cursor
()
...
...
@@ -177,7 +179,7 @@ def main():
parser
.
add_option
(
"--dry-run"
,
action
=
"store_true"
,
help
=
"print destinations instead of delivering mails"
)
(
opts
,
args
)
=
parser
.
parse_args
()
dispatcher
=
Dispatcher
(
sys
.
stdin
,
destdir
=
opts
.
dest
)
dispatcher
=
Dispatcher
(
sys
.
stdin
.
buffer
,
destdir
=
opts
.
dest
)
if
opts
.
dry_run
:
msgid
=
dispatcher
.
msg
.
get
(
"message-id"
,
"(no message id)"
)
try
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment