Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
892a1502
Commit
892a1502
authored
5 months ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
DSN: process-dsn už nepotřebujeme
parent
a6b4fd87
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/process-dsn
+0
-70
0 additions, 70 deletions
bin/process-dsn
with
0 additions
and
70 deletions
bin/process-dsn
deleted
100755 → 0
+
0
−
70
View file @
a6b4fd87
#!/usr/bin/env python3
# XXX: Work in progress :XXX
import
email.message
import
email.parser
import
email.policy
import
sys
# import mo.db as db
# import mo.email
# import mo.users
import
mo.util
mo
.
util
.
init_standalone
()
class
DSN
:
msg
:
email
.
message
.
EmailMessage
message_id
:
str
parse_status
:
str
dsn_action
:
str
dsn_status
:
str
def
__init__
(
self
):
parser
=
email
.
parser
.
Parser
(
policy
=
email
.
policy
.
default
)
self
.
msg
=
parser
.
parse
(
sys
.
stdin
)
self
.
message_id
=
(
self
.
msg
[
'
Message-Id
'
]
or
'
?
'
).
strip
()
self
.
dsn_action
=
'
?
'
self
.
dsn_status
=
'
?
'
self
.
parse_status
=
self
.
parse_dsn
()
def
parse_dsn
(
self
)
->
str
:
if
self
.
msg
.
get_content_type
()
!=
'
multipart/report
'
:
return
'
unexpected content-type
'
if
not
self
.
msg
.
is_multipart
():
return
'
not multipart
'
report_type
=
self
.
msg
[
'
Content-type
'
].
params
.
get
(
'
report-type
'
,
'
?
'
)
if
report_type
!=
'
delivery-status
'
:
return
'
unknown report-type
'
if
len
(
self
.
msg
.
get_payload
())
<
2
:
return
'
too few parts
'
part2
=
self
.
msg
.
get_payload
(
1
)
if
part2
.
get_content_type
()
!=
'
message/delivery-status
'
:
return
'
unexpected part 2 type
'
dsn
=
part2
.
get_payload
()
if
len
(
dsn
)
<
2
:
return
'
DSN too short
'
# main = dsn[0]
per_addr
=
dsn
[
1
]
self
.
dsn_action
=
per_addr
[
'
Action
'
]
self
.
dsn_status
=
per_addr
[
'
Status
'
]
if
self
.
dsn_action
!=
'
failed
'
:
return
'
not failed
'
print
(
self
.
msg
.
get_payload
(
2
).
get_content_type
())
return
'
ok
'
dsn
=
DSN
()
print
(
f
'
DSN:
{
dsn
.
message_id
}
{
dsn
.
parse_status
}
{
dsn
.
dsn_action
}
{
dsn
.
dsn_status
}
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment