Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gajim-plugins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Evert Mouw
gajim-plugins
Commits
cdc892c6
Commit
cdc892c6
authored
11 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
add 1 day timeout for reminders and prevent some traceback when date format is not correct
parent
7d176c53
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
birthday_reminder/manifest.ini
+1
-1
1 addition, 1 deletion
birthday_reminder/manifest.ini
birthday_reminder/plugin.py
+20
-11
20 additions, 11 deletions
birthday_reminder/plugin.py
with
21 additions
and
12 deletions
birthday_reminder/manifest.ini
+
1
−
1
View file @
cdc892c6
[info]
[info]
name:
Birthday
reminder
name:
Birthday
reminder
short_name:
birthday_reminder
short_name:
birthday_reminder
version:
0.0.
1
version:
0.0.
2
description:
Birthday
reminder
plugin
description:
Birthday
reminder
plugin
authors:
Evgeniy
Popov
<evgeniypopov@gmail.com>
authors:
Evgeniy
Popov
<evgeniypopov@gmail.com>
homepage:
https://bitbucket.org/axce1/bday
homepage:
https://bitbucket.org/axce1/bday
This diff is collapsed.
Click to expand it.
birthday_reminder/plugin.py
+
20
−
11
View file @
cdc892c6
...
@@ -2,6 +2,7 @@ import os
...
@@ -2,6 +2,7 @@ import os
import
glob
import
glob
import
datetime
import
datetime
from
xml.dom.minidom
import
*
from
xml.dom.minidom
import
*
import
gobject
from
plugins
import
GajimPlugin
from
plugins
import
GajimPlugin
from
plugins.helpers
import
log_calls
from
plugins.helpers
import
log_calls
...
@@ -20,11 +21,9 @@ class BirthDayPlugin(GajimPlugin):
...
@@ -20,11 +21,9 @@ class BirthDayPlugin(GajimPlugin):
configpath
=
configpaths
.
ConfigPaths
()
configpath
=
configpaths
.
ConfigPaths
()
cache_path
=
configpath
.
cache_root
cache_path
=
configpath
.
cache_root
self
.
vcard_path
=
os
.
path
.
join
(
cache_path
,
'
vcards
'
)
+
os
.
sep
self
.
vcard_path
=
os
.
path
.
join
(
cache_path
,
'
vcards
'
)
+
os
.
sep
self
.
timeout_id
=
0
def
check_birthdays
(
self
):
@log_calls
(
'
BirthDayPlugin
'
)
def
activate
(
self
):
vcards
=
[]
vcards
=
[]
date_dict
=
{}
date_dict
=
{}
for
jid
in
glob
.
glob
(
self
.
vcard_path
+
'
*@*
'
):
for
jid
in
glob
.
glob
(
self
.
vcard_path
+
'
*@*
'
):
...
@@ -34,24 +33,26 @@ class BirthDayPlugin(GajimPlugin):
...
@@ -34,24 +33,26 @@ class BirthDayPlugin(GajimPlugin):
for
xmldoc
in
vcards
:
for
xmldoc
in
vcards
:
try
:
try
:
xml
=
parse
(
xmldoc
)
xml
=
parse
(
xmldoc
)
except
:
except
:
pass
pass
else
:
else
:
name
=
xml
.
getElementsByTagName
(
'
BDAY
'
)
name
=
xml
.
getElementsByTagName
(
'
BDAY
'
)
for
node
in
name
:
for
node
in
name
:
try
:
try
:
data
=
node
.
childNodes
[
0
].
nodeValue
data
=
node
.
childNodes
[
0
].
nodeValue
date_dict
[
xmldoc
[
len
(
self
.
vcard_path
):]]
=
data
date_dict
[
xmldoc
[
len
(
self
.
vcard_path
):]]
=
data
except
:
pass
except
:
pass
today
=
datetime
.
date
.
today
()
today
=
datetime
.
date
.
today
()
for
key
,
value
in
date_dict
.
iteritems
():
for
key
,
value
in
date_dict
.
iteritems
():
convert_date
=
datetime
.
datetime
.
strptime
(
value
,
"
%Y-%m-%d
"
)
try
:
user_bday
=
datetime
.
date
(
convert_date
=
datetime
.
datetime
.
strptime
(
value
,
"
%Y-%m-%d
"
)
today
.
year
,
convert_date
.
month
,
convert_date
.
day
)
user_bday
=
datetime
.
date
(
today
.
year
,
convert_date
.
month
,
convert_date
.
day
)
except
:
continue
if
user_bday
<
today
:
if
user_bday
<
today
:
user_bday
=
user_bday
.
replace
(
year
=
today
.
year
+
1
)
user_bday
=
user_bday
.
replace
(
year
=
today
.
year
+
1
)
...
@@ -72,8 +73,16 @@ class BirthDayPlugin(GajimPlugin):
...
@@ -72,8 +73,16 @@ class BirthDayPlugin(GajimPlugin):
text
=
"
Today BDay %s
"
%
key
text
=
"
Today BDay %s
"
%
key
if
text
:
if
text
:
popup
(
''
,
key
,
key
,
title
=
title
,
text
=
text
)
popup
(
''
,
key
,
key
,
title
=
title
,
text
=
text
)
return
True
@log_calls
(
'
BirthDayPlugin
'
)
def
activate
(
self
):
self
.
check_birthdays
()
self
.
timeout_id
=
gobject
.
timeout_add_seconds
(
24
*
3600
,
self
.
check_birthdays
)
@log_calls
(
'
BirthDayPlugin
'
)
@log_calls
(
'
BirthDayPlugin
'
)
def
deactivate
(
self
):
def
deactivate
(
self
):
pass
if
self
.
timeout_id
>
0
:
gobject
.
source_remove
(
self
.
timeout_id
)
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