Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Citronalco
carddav2asterisk
Commits
9f64ccef
Commit
9f64ccef
authored
Aug 16, 2018
by
Citronalco
Browse files
some clean up
parent
f0a16fd0
Changes
1
Hide whitespace changes
Inline
Side-by-side
carddav2asterisk.py
View file @
9f64ccef
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import
sys
reload
(
sys
)
sys
.
setdefaultencoding
(
'utf8'
)
import
requests
import
vobject
import
re
import
time
from
asterisk
import
manager
from
requests.auth
import
HTTPBasicAuth
from
lxml
import
etree
...
...
@@ -54,7 +52,6 @@ def main(argv):
ami
.
login
(
USER
,
PASS
)
# get phone numbers from vcard
starttime
=
int
(
time
.
time
());
for
vurl
in
getAllVcardLinks
(
url
,
auth
):
r
=
requests
.
request
(
"GET"
,
vurl
,
auth
=
auth
)
vcard
=
vobject
.
readOne
(
r
.
content
)
...
...
@@ -63,14 +60,14 @@ def main(argv):
num
=
tidyPhoneNumber
(
telno
.
value
)
if
"fn"
in
vcard
.
contents
:
name
=
vcard
.
fn
.
value
print
"Adding/updating Number: "
+
num
+
" Name: "
+
name
print
(
"Adding/updating Number: "
+
num
+
" Name: "
+
name
)
ami
.
send_action
({
"Action"
:
"DBPut"
,
"Family"
:
"cidname"
,
"Key"
:
num
,
"Val"
:
name
})
ami
.
logoff
()
ami
.
close
()
if
__name__
==
"__main__"
:
if
len
(
sys
.
argv
)
!=
4
:
print
"Must be called with eight arguments: <carddav-url> <carddav-user> <carddav-password>"
print
"Example: %s https://owncloud.example.com/remote.php/dav/addressbooks/users/russmeyer/contacts/ meyerr p8a55w0rd"
%
sys
.
argv
[
0
]
print
(
"Must be called with eight arguments: <carddav-url> <carddav-user> <carddav-password>"
)
print
(
"Example: %s https://owncloud.example.com/remote.php/dav/addressbooks/users/russmeyer/contacts/ meyerr p8a55w0rd"
%
sys
.
argv
[
0
]
)
sys
.
exit
(
1
)
sys
.
exit
(
main
(
sys
.
argv
))
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