Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mp3wavweb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mp3wavweb
mp3wavweb
Commits
73037e91
Commit
73037e91
authored
Mar 09, 2014
by
Per Cederqvist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring: extract get_daemon_connection() from convert().
parent
7d71e4a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
17 deletions
+20
-17
mp3wavweb.py
mp3wavweb.py
+20
-17
No files found.
mp3wavweb.py
View file @
73037e91
...
...
@@ -90,23 +90,7 @@ def process_request(environ, start_response):
else
:
raise
NotFound
()
def
convert
(
environ
,
start_response
,
ph
):
if
len
(
ph
.
op_args
())
>
0
:
raise
NotFound
()
if
environ
[
"REQUEST_METHOD"
]
==
"GET"
:
start_response
(
"200 OK"
,
[(
'Content-Type'
,
'text/html;charset=utf-8'
)])
return
[
"<!DOCTYPE HTML PUBLIC
\"
-//W3C//DTD HTML 4.01//EN
\"\n
"
"
\"
http://www.w3.org/TR/html4/strict.dtd
\"
>
\n
"
"<html><head><title>Request conversion</title></head>
\n
"
"<body><form method=
\"
POST
\"
action=
\"
convert
\"
>
\n
"
"<button>Confirm conversion to mp3</button>
\n
"
"</form></body></html>"
]
if
environ
[
"REQUEST_METHOD"
]
!=
"POST"
:
raise
MethodNotAllowed
(
'GET, POST'
)
def
get_daemon_connection
():
try
:
c
=
multiprocessing
.
connection
.
Client
(
mp3wavcfg
.
socketpath
,
'AF_UNIX'
)
except
FileNotFoundError
:
...
...
@@ -127,7 +111,26 @@ def convert(environ, start_response, ph):
sys
.
stderr
.
write
(
"Connecting to new wav2mp3d.
\n
"
)
c
=
multiprocessing
.
connection
.
Client
(
mp3wavcfg
.
socketpath
,
'AF_UNIX'
)
sys
.
stderr
.
write
(
"Connected to new wav2mp3d.
\n
"
)
return
c
def
convert
(
environ
,
start_response
,
ph
):
if
len
(
ph
.
op_args
())
>
0
:
raise
NotFound
()
if
environ
[
"REQUEST_METHOD"
]
==
"GET"
:
start_response
(
"200 OK"
,
[(
'Content-Type'
,
'text/html;charset=utf-8'
)])
return
[
"<!DOCTYPE HTML PUBLIC
\"
-//W3C//DTD HTML 4.01//EN
\"\n
"
"
\"
http://www.w3.org/TR/html4/strict.dtd
\"
>
\n
"
"<html><head><title>Request conversion</title></head>
\n
"
"<body><form method=
\"
POST
\"
action=
\"
convert
\"
>
\n
"
"<button>Confirm conversion to mp3</button>
\n
"
"</form></body></html>"
]
if
environ
[
"REQUEST_METHOD"
]
!=
"POST"
:
raise
MethodNotAllowed
(
'GET, POST'
)
c
=
get_daemon_connection
()
c
.
send
((
"encode"
,
ph
.
rel_base
()))
while
True
:
msg
=
c
.
recv
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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