Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
Added support for Python 3.
Browse files Browse the repository at this point in the history
Modified README.textile to incorporate instructions for installing (Ubuntu) in Python 3.
Modified setup.py to make setup_tools automatically convert the Python 2 code using 2to3.
Modified lcdproc/server.py to change the type of the variables in- and outputted to the telnetlib to bytes.
  • Loading branch information
CriminalK committed Feb 8, 2013
1 parent 28ac34c commit 4594117
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
9 changes: 8 additions & 1 deletion README.textile
Expand Up @@ -2,9 +2,16 @@ h2. LCDproc

h3. Installing

h4. Python 2:
bc. sudo apt-get install python-setuptools
sudo easy_install lcdproc

h4. Python 3:
bc. sudo apt-get install python3-setuptools
sudo easy_install3 lcdproc

Alternatively, you could use pip to install the package instead of easy_install.

h3. Example Usage

See *examples.py*
See *examples.py*
10 changes: 5 additions & 5 deletions lcdproc/server.py
Expand Up @@ -42,14 +42,14 @@ def request(self, command_string):

""" Request """

self.tn.write(command_string + "\n")
self.tn.write((command_string + "\n").encode())
if self.debug: print "Telnet Request: %s" % (command_string)
while True:
response = urllib.unquote(self.tn.read_until("\n"))
response = urllib.unquote(self.tn.read_until(b"\n").decode())
if "success" in response: # Normal successful reply
break
if "huh" in response: # Something went wrong
break
break
if "connect" in response: # Special reply to "hello"
break
# TODO Keep track of which screen is displayed
Expand All @@ -66,7 +66,7 @@ def poll(self):
LCDd generates strings for key presses, menu events & screen visibility changes.
"""
if select.select([self.tn], [], [], 0) == ([self.tn], [], []):
response = urllib.unquote(self.tn.read_until("\n"))
response = urllib.unquote(self.tn.read_until(b"\n").decode())
if self.debug: print "Telnet Poll: %s" % (response[:-1])
# TODO Keep track of which screen is displayed
return response
Expand Down Expand Up @@ -132,7 +132,7 @@ def output(self, value):
Return None or LCDd response on error
"""
response = self.request("output %s" % (value))
response = self.request(("output %s" % (value)).encode())
if "success" in response:
return None
else:
Expand Down
10 changes: 8 additions & 2 deletions setup.py
@@ -1,7 +1,12 @@
#import ez_setup, os
#ez_setup.use_setuptools()
import os
import os, sys
from setuptools import setup, find_packages

extra = {}
if sys.version_info >= (3,):
extra['use_2to3'] = True

setup(
name = "lcdproc",
version = "0.03",
Expand All @@ -11,5 +16,6 @@
url = "http://github.com/jingleman/lcdproc",
packages = find_packages(),
scripts = [],
include_package_data = True
include_package_data = True,
**extra
)

0 comments on commit 4594117

Please sign in to comment.