Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SickRage-1
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
SickRage-1
Commits
a8ed3bbe
Commit
a8ed3bbe
authored
Aug 13, 2015
by
miigotu
Browse files
Options
Downloads
Plain Diff
Merge pull request #2295 from SiCKRAGETV/update-pynma
Update pynma to 1.0
parents
2def7332
4f4bb478
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/pynma/__init__.py
+1
-2
1 addition, 2 deletions
lib/pynma/__init__.py
lib/pynma/pynma.py
+40
-31
40 additions, 31 deletions
lib/pynma/pynma.py
sickbeard/notifiers/nma.py
+2
-2
2 additions, 2 deletions
sickbeard/notifiers/nma.py
with
43 additions
and
35 deletions
lib/pynma/__init__.py
+
1
−
2
View file @
a8ed3bbe
#!/usr/bin/python
#!/usr/bin/python
from
pynma
import
PyNMA
from
.pynma
import
PyNMA
This diff is collapsed.
Click to expand it.
lib/pynma/pynma.py
+
40
−
31
View file @
a8ed3bbe
#!/usr/bin/python
#!/usr/bin/python
from
xml.dom.minidom
import
parseString
from
xml.dom.minidom
import
parseString
try
:
from
http.client
import
HTTPSConnection
except
ImportError
:
from
httplib
import
HTTPSConnection
from
httplib
import
HTTPSConnection
try
:
from
urllib.parse
import
urlencode
except
ImportError
:
from
urllib
import
urlencode
from
urllib
import
urlencode
__version__
=
"
0.1
"
__version__
=
"
1.0
"
API_SERVER
=
'
www.notifymyandroid.com
'
API_SERVER
=
'
www.notifymyandroid.com
'
ADD_PATH
=
'
/publicapi/notify
'
ADD_PATH
=
'
/publicapi/notify
'
...
@@ -18,7 +26,7 @@ def uniq_preserve(seq): # Dave Kirby
...
@@ -18,7 +26,7 @@ def uniq_preserve(seq): # Dave Kirby
def
uniq
(
seq
):
def
uniq
(
seq
):
# Not order preserving
# Not order preserving
return
{}.
fromkeys
(
seq
).
keys
()
return
list
(
{}.
fromkeys
(
seq
).
keys
()
)
class
PyNMA
(
object
):
class
PyNMA
(
object
):
"""
PyNMA(apikey=[], developerkey=None)
"""
PyNMA(apikey=[], developerkey=None)
...
@@ -60,16 +68,17 @@ class PyNMA(object):
...
@@ -60,16 +68,17 @@ class PyNMA(object):
if
type
(
developerkey
)
==
str
and
len
(
developerkey
)
==
48
:
if
type
(
developerkey
)
==
str
and
len
(
developerkey
)
==
48
:
self
.
_developerkey
=
developerkey
self
.
_developerkey
=
developerkey
def
push
(
self
,
application
=
""
,
event
=
""
,
description
=
""
,
url
=
""
,
priority
=
0
,
batch_mode
=
False
):
def
push
(
self
,
application
=
""
,
event
=
""
,
description
=
""
,
url
=
""
,
contenttype
=
None
,
priority
=
0
,
batch_mode
=
False
,
html
=
False
):
"""
Pushes a message on the registered API keys.
"""
Pushes a message on the registered API keys.
takes 5 arguments:
takes 5 arguments:
- (req) application: application name [256]
- (req) application: application name [256]
- (req) event: event name [1000]
- (req) event: event name [1000]
- (req) description: description [10000]
- (req) description: description [10000]
- (opt) url: url [512]
- (opt) url: url [512]
- (opt) contenttype: Content Type (act: None (plain text) or text/html)
- (opt) priority: from -2 (lowest) to 2 (highest) (def:0)
- (opt) priority: from -2 (lowest) to 2 (highest) (def:0)
- (opt) batch_mode:
call API 5 by 5
(def:False)
- (opt) batch_mode:
push to all keys at once
(def:False)
- (opt) html: shortcut for contenttype=text/html
Warning: using batch_mode will return error only if all API keys are bad
Warning: using batch_mode will return error only if all API keys are bad
cf: http://nma.usk.bz/api.php
cf: http://nma.usk.bz/api.php
"""
"""
...
@@ -83,6 +92,9 @@ class PyNMA(object):
...
@@ -83,6 +92,9 @@ class PyNMA(object):
if
url
:
if
url
:
datas
[
'
url
'
]
=
url
[:
512
]
datas
[
'
url
'
]
=
url
[:
512
]
if
contenttype
==
"
text/html
"
or
html
==
True
:
# Currently only accepted content type
datas
[
'
content-type
'
]
=
"
text/html
"
if
self
.
_developerkey
:
if
self
.
_developerkey
:
datas
[
'
developerkey
'
]
=
self
.
_developerkey
datas
[
'
developerkey
'
]
=
self
.
_developerkey
...
@@ -94,8 +106,7 @@ class PyNMA(object):
...
@@ -94,8 +106,7 @@ class PyNMA(object):
res
=
self
.
callapi
(
'
POST
'
,
ADD_PATH
,
datas
)
res
=
self
.
callapi
(
'
POST
'
,
ADD_PATH
,
datas
)
results
[
key
]
=
res
results
[
key
]
=
res
else
:
else
:
for
i
in
range
(
0
,
len
(
self
.
_apikey
),
5
):
datas
[
'
apikey
'
]
=
"
,
"
.
join
(
self
.
_apikey
)
datas
[
'
apikey
'
]
=
"
,
"
.
join
(
self
.
_apikey
[
i
:
i
+
5
])
res
=
self
.
callapi
(
'
POST
'
,
ADD_PATH
,
datas
)
res
=
self
.
callapi
(
'
POST
'
,
ADD_PATH
,
datas
)
results
[
datas
[
'
apikey
'
]]
=
res
results
[
datas
[
'
apikey
'
]]
=
res
return
results
return
results
...
@@ -110,7 +121,7 @@ class PyNMA(object):
...
@@ -110,7 +121,7 @@ class PyNMA(object):
try
:
try
:
res
=
self
.
_parse_reponse
(
resp
.
read
())
res
=
self
.
_parse_reponse
(
resp
.
read
())
except
Exception
,
e
:
except
Exception
as
e
:
res
=
{
'
type
'
:
"
pynmaerror
"
,
res
=
{
'
type
'
:
"
pynmaerror
"
,
'
code
'
:
600
,
'
code
'
:
600
,
'
message
'
:
str
(
e
)
'
message
'
:
str
(
e
)
...
@@ -124,14 +135,12 @@ class PyNMA(object):
...
@@ -124,14 +135,12 @@ class PyNMA(object):
for
elem
in
root
.
childNodes
:
for
elem
in
root
.
childNodes
:
if
elem
.
nodeType
==
elem
.
TEXT_NODE
:
continue
if
elem
.
nodeType
==
elem
.
TEXT_NODE
:
continue
if
elem
.
tagName
==
'
success
'
:
if
elem
.
tagName
==
'
success
'
:
res
=
dict
(
elem
.
attributes
.
items
())
res
=
dict
(
list
(
elem
.
attributes
.
items
())
)
res
[
'
message
'
]
=
""
res
[
'
message
'
]
=
""
res
[
'
type
'
]
=
elem
.
tagName
res
[
'
type
'
]
=
elem
.
tagName
return
res
return
res
if
elem
.
tagName
==
'
error
'
:
if
elem
.
tagName
==
'
error
'
:
res
=
dict
(
elem
.
attributes
.
items
())
res
=
dict
(
list
(
elem
.
attributes
.
items
())
)
res
[
'
message
'
]
=
elem
.
firstChild
.
nodeValue
res
[
'
message
'
]
=
elem
.
firstChild
.
nodeValue
res
[
'
type
'
]
=
elem
.
tagName
res
[
'
type
'
]
=
elem
.
tagName
return
res
return
res
This diff is collapsed.
Click to expand it.
sickbeard/notifiers/nma.py
+
2
−
2
View file @
a8ed3bbe
...
@@ -52,7 +52,7 @@ class NMA_Notifier:
...
@@ -52,7 +52,7 @@ class NMA_Notifier:
if
len
(
keys
)
>
1
:
batch
=
True
if
len
(
keys
)
>
1
:
batch
=
True
logger
.
log
(
"
NMA: Sending notice with details: event=
\"
%s
\"
, message=
\"
%s
\"
, priority=%s, batch=%s
"
%
(
event
,
message
,
nma_priority
,
batch
),
logger
.
DEBUG
)
logger
.
log
(
"
NMA: Sending notice with details: event=
\"
%s
\"
, message=
\"
%s
\"
, priority=%s, batch=%s
"
%
(
event
,
message
,
nma_priority
,
batch
),
logger
.
DEBUG
)
response
=
p
.
push
(
title
,
event
,
message
,
priority
=
nma_priority
,
batch_mode
=
batch
)
response
=
p
.
push
(
application
=
title
,
event
=
event
,
description
=
message
,
priority
=
nma_priority
,
batch_mode
=
batch
)
if
not
response
[
nma_api
][
u
'
code
'
]
==
u
'
200
'
:
if
not
response
[
nma_api
][
u
'
code
'
]
==
u
'
200
'
:
logger
.
log
(
u
'
Could not send notification to NotifyMyAndroid
'
,
logger
.
ERROR
)
logger
.
log
(
u
'
Could not send notification to NotifyMyAndroid
'
,
logger
.
ERROR
)
...
...
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