Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
daily-scripts
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
daily-scripts
Commits
931ec8a8
There was an error fetching the commit references. Please try again later.
Commit
931ec8a8
authored
2 months ago
by
Recolic
Browse files
Options
Downloads
Patches
Plain Diff
.
parent
aae03f0b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
archived/py/listemail2.py
+63
-0
63 additions, 0 deletions
archived/py/listemail2.py
linuxconf/files/mybin/rwatchdog.sh
+1
-1
1 addition, 1 deletion
linuxconf/files/mybin/rwatchdog.sh
with
64 additions
and
1 deletion
archived/py/listemail.py
→
archived/py/listemail
2
.py
+
63
−
0
View file @
931ec8a8
#
usage:
python archived/py/listemail.py (genpasswd btest@recolic.net)
# python archived/py/listemail
2
.py (genpasswd btest@recolic.net)
import
imaplib
import
imaplib
import
email
import
email
import
re
from
email.header
import
decode_header
from
email.header
import
decode_header
import
sys
import
sys
IMAP_SERVER
=
"
imap.recolic.net
"
IMAP_SERVER
=
"
imap.recolic.net
"
USERNAME
=
"
btest@recolic.net
"
USERNAME
=
"
btest@recolic.net
"
PASSWORD
=
sys
.
argv
[
1
]
PASSWORD
=
sys
.
argv
[
1
]
Search_Regex
=
r
"
<b>\$[0-9\.]*</b>
"
# Connect and upgrade to TLS
# Connect and upgrade to TLS
mail
=
imaplib
.
IMAP4
(
IMAP_SERVER
,
143
)
mail
=
imaplib
.
IMAP4
(
IMAP_SERVER
,
143
)
...
@@ -22,20 +24,40 @@ if status != "OK":
...
@@ -22,20 +24,40 @@ if status != "OK":
print
(
"
Failed to fetch emails
"
)
print
(
"
Failed to fetch emails
"
)
exit
()
exit
()
# Get list of email IDs
email_ids
=
messages
[
0
].
split
()
email_ids
=
messages
[
0
].
split
()
# Fetch and print subject lines
for
eid
in
email_ids
:
for
eid
in
email_ids
:
status
,
msg_data
=
mail
.
fetch
(
eid
,
"
(RFC822
.HEADER
)
"
)
status
,
msg_data
=
mail
.
fetch
(
eid
,
"
(RFC822)
"
)
if
status
!=
"
OK
"
:
if
status
!=
"
OK
"
:
continue
continue
msg
=
email
.
message_from_bytes
(
msg_data
[
0
][
1
])
msg
=
email
.
message_from_bytes
(
msg_data
[
0
][
1
])
# Decode subject
subject
,
encoding
=
decode_header
(
msg
[
"
Subject
"
])[
0
]
subject
,
encoding
=
decode_header
(
msg
[
"
Subject
"
])[
0
]
if
isinstance
(
subject
,
bytes
):
if
isinstance
(
subject
,
bytes
):
subject
=
subject
.
decode
(
encoding
or
"
utf-8
"
,
errors
=
"
ignore
"
)
subject
=
subject
.
decode
(
encoding
or
"
utf-8
"
,
errors
=
"
ignore
"
)
print
(
subject
)
print
(
f
"
Subject:
{
subject
}
"
)
# Extract body
body
=
""
if
msg
.
is_multipart
():
for
part
in
msg
.
walk
():
content_type
=
part
.
get_content_type
()
if
content_type
==
"
text/html
"
:
try
:
body
=
part
.
get_payload
(
decode
=
True
).
decode
(
part
.
get_content_charset
()
or
"
utf-8
"
,
errors
=
"
ignore
"
)
break
except
:
continue
else
:
if
msg
.
get_content_type
()
==
"
text/html
"
:
body
=
msg
.
get_payload
(
decode
=
True
).
decode
(
msg
.
get_content_charset
()
or
"
utf-8
"
,
errors
=
"
ignore
"
)
# Regex matches
matches
=
re
.
findall
(
Search_Regex
,
body
)
for
m
in
matches
:
print
(
f
"
Match:
{
m
}
"
)
mail
.
logout
()
mail
.
logout
()
This diff is collapsed.
Click to expand it.
linuxconf/files/mybin/rwatchdog.sh
+
1
−
1
View file @
931ec8a8
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
# const variables
# const variables
MORNING_ALARM
=
"0
8
:17"
MORNING_ALARM
=
"
1
0:17"
[[
$1
=
daemon
]]
&&
cloudalarm_token
=
$(
rsec WEAK10
)
[[
$1
=
daemon
]]
&&
cloudalarm_token
=
$(
rsec WEAK10
)
TMP_CTL_FILE
=
/tmp/.rwatchdog.cmd
TMP_CTL_FILE
=
/tmp/.rwatchdog.cmd
TMP_INFO_FILE
=
/tmp/.rwatchdog.alarm-info
TMP_INFO_FILE
=
/tmp/.rwatchdog.alarm-info
...
...
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