Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CouchPotatoServer
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
CouchPotatoServer
Commits
bcdc633a
Commit
bcdc633a
authored
Oct 21, 2012
by
Ruud
Browse files
Options
Downloads
Patches
Plain Diff
Use urlopen for Prowl notifier. fix #932
parent
19f74e39
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
couchpotato/core/notifications/prowl/main.py
+15
-19
15 additions, 19 deletions
couchpotato/core/notifications/prowl/main.py
with
15 additions
and
19 deletions
couchpotato/core/notifications/prowl/main.py
+
15
−
19
View file @
bcdc633a
from
couchpotato.core.helpers.encoding
import
toUnicode
,
tryUrlencode
from
couchpotato.core.helpers.encoding
import
toUnicode
from
couchpotato.core.logger
import
CPLog
from
couchpotato.core.notifications.base
import
Notification
from
httplib
import
HTTPSConnection
import
traceback
log
=
CPLog
(
__name__
)
class
Prowl
(
Notification
):
urls
=
{
'
api
'
:
'
https://api.prowlapp.com/publicapi/add
'
}
def
notify
(
self
,
message
=
''
,
data
=
{},
listener
=
None
):
if
self
.
isDisabled
():
return
http_handler
=
HTTPSConnection
(
'
api.prowlapp.com
'
)
data
=
{
'
apikey
'
:
self
.
conf
(
'
api_key
'
),
'
application
'
:
self
.
default_title
,
'
description
'
:
toUnicode
(
message
),
'
priority
'
:
self
.
conf
(
'
priority
'
),
}
headers
=
{
'
Content-type
'
:
'
application/x-www-form-urlencoded
'
}
http_handler
.
request
(
'
POST
'
,
'
/publicapi/add
'
,
headers
=
{
'
Content-type
'
:
'
application/x-www-form-urlencoded
'
},
body
=
tryUrlencode
(
data
)
)
response
=
http_handler
.
getresponse
()
request_status
=
response
.
status
if
request_status
==
200
:
try
:
self
.
urlopen
(
self
.
urls
[
'
api
'
],
headers
=
headers
,
params
=
data
,
multipart
=
True
,
show_error
=
False
)
log
.
info
(
'
Prowl notifications sent.
'
)
return
True
elif
request_status
==
401
:
log
.
error
(
'
Prowl auth failed: %s
'
,
response
.
reason
)
return
False
else
:
log
.
error
(
'
Prowl notification failed.
'
)
except
:
log
.
error
(
'
Prowl failed: %s
'
,
traceback
.
format_exc
())
return
False
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