Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aliveNotifier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
kpetersn
aliveNotifier
Commits
78343205
Commit
78343205
authored
10 years ago
by
kpetersn
Browse files
Options
Downloads
Patches
Plain Diff
Use time from xml instead of time.asctime()
parent
ca28fe23
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
an.py
+11
-8
11 additions, 8 deletions
an.py
with
11 additions
and
8 deletions
an.py
+
11
−
8
View file @
78343205
...
...
@@ -7,7 +7,8 @@
import
urllib
import
xml.etree.ElementTree
as
ET
import
time
# for time.asctime()
#!import time
# needed for notifyOSX()
import
os
...
...
@@ -18,13 +19,11 @@ engineer = "Peterson"
# period should match cron job period
period
=
120
def
notifyConsole
(
ioc
,
state
):
notify_time
=
time
.
asctime
()
print
"
[%s] %s is %s
"
%
(
notify_time
,
ioc
,
state
)
def
notifyConsole
(
ioc
,
state
,
time_str
):
print
"
[%s] %s is %s
"
%
(
time_str
,
ioc
,
state
)
def
notifyOSX
(
ioc
,
state
):
notify_time
=
time
.
asctime
()
notify_command
=
"
%s -title
\"
%s is %s
\"
-message
\"
%s
\"
"
%
(
osx_command
,
ioc
,
state
,
notify_time
)
def
notifyOSX
(
ioc
,
state
,
time_str
):
notify_command
=
"
%s -title
\"
%s is %s
\"
-message
\"
%s
\"
"
%
(
osx_command
,
ioc
,
state
,
time_str
)
os
.
system
(
notify_command
)
# set notification function
...
...
@@ -47,6 +46,10 @@ f.close()
#!print "Parsing XML"
root
=
ET
.
fromstring
(
xml_string
)
# Get the date and time
time_elem
=
root
.
find
(
'
time
'
)
time_str
=
time_elem
.
text
# Indent for making ET.tostring() output readable
def
_indent
(
elem
,
level
=
0
):
'''
...
...
@@ -111,4 +114,4 @@ iocs = ioc_list.keys()
iocs
.
sort
()
for
ioc
in
iocs
:
notify
(
ioc
,
ioc_list
[
ioc
])
notify
(
ioc
,
ioc_list
[
ioc
]
,
time_str
)
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