Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
07cf32d6
Commit
07cf32d6
authored
Jun 03, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update RPC server, try to bind another port if requested one is in use
parent
1bd4155b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
rpc.py
printrun/rpc.py
+34
-4
No files found.
printrun/rpc.py
View file @
07cf32d6
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
from
SimpleXMLRPCServer
import
SimpleXMLRPCServer
from
threading
import
Thread
import
socket
import
logging
from
.utils
import
parse_temperature_report
from
.utils
import
install_locale
,
parse_temperature_report
install_locale
(
'pronterface'
)
RPC_PORT
=
7978
...
...
@@ -11,9 +29,21 @@ class ProntRPC(object):
def
__init__
(
self
,
pronsole
,
port
=
RPC_PORT
):
self
.
pronsole
=
pronsole
self
.
server
=
SimpleXMLRPCServer
((
"localhost"
,
port
),
allow_none
=
True
,
logRequests
=
False
)
used_port
=
port
while
True
:
try
:
self
.
server
=
SimpleXMLRPCServer
((
"localhost"
,
used_port
),
allow_none
=
True
,
logRequests
=
False
)
if
used_port
!=
port
:
logging
.
warning
(
_
(
"RPC server bound on non-default port
%
d"
)
%
used_port
)
break
except
socket
.
error
as
e
:
if
e
.
errno
==
98
:
used_port
+=
1
continue
else
:
raise
self
.
server
.
register_function
(
self
.
get_status
,
'status'
)
self
.
thread
=
Thread
(
target
=
self
.
run_server
)
self
.
thread
.
start
()
...
...
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