Skip to content

Commit

Permalink
Python3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
thehappydinoa committed May 26, 2018
1 parent f394b34 commit f414eb1
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 55 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
__pychache__/
*.pyc
build/
dist/
aquosRemote.egg-info/
venv/
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ Usage

.. code:: python
from aquosRemote import aquosTV
from aquosRemote.aquos import aquosTV
aquos = aquosTV('TV', 'IP.ADD.RESS.XX')
aquos = aquosTV('IP.ADD.RESS.XX')
- TV Commands
Expand Down Expand Up @@ -91,17 +91,17 @@ An example program would look like:

.. code:: python
from aquosRemote import aquosTV
from aquosRemote.aquos import aquosTV
aquos = aquosTV('TV', 'IP.ADD.RESS.XX') # Without Auth
aquos = aquosTV('TV', 'IP.ADD.RESS.XX', 'username','password') # With Auth
aquos = aquosTV('IP.ADD.RESS.XX') # Without Auth
aquos = aquosTV('IP.ADD.RESS.XX', 'username', 'password') # With Auth
aquos.tv_on()
...
DEPENDENCIES
------------

This has been tested with Python 2.6 and 2.7.
This has been tested with Python 2.6 and Python 3.6.

LICENSE
-------
Expand Down
1 change: 0 additions & 1 deletion aquosRemote/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from aquos import *
34 changes: 11 additions & 23 deletions aquosRemote/aquos.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,29 @@
import socket
from contextlib import closing

important = "\033[35m[*]\033[1;m "
hardreturn = "\n"
info = "\033[1;33m[!]\033[1;m "
que = "\033[1;34m[?]\033[1;m "
bad = "\033[1;31m[-]\033[1;m "
good = "\033[1;32m[+]\033[1;m "
run = "\033[1;97m[~]\033[1;m "


class aquosTV(object):
def __init__(self, name, ip, port=10002, username=None, password=None):
self.name = name
def __init__(self, ip, port=10002, username=None, password=None):
self.ip = str(ip)
self.port = int(port)
self.username = username
self.password = password
if not self._check_ip():
print(bad + "Port %s is not open on %s" % (self.port, self.ip))
# raise Exception("Port %s is not open on %s" % (self.port, self.ip))
print(good + "Created '%s' on %s:%s" %
(self.name, self.ip, str(self.port)))
raise Exception("Port %s is not open on %s" % (self.port, self.ip))

def send_command(self, command, byte_size=1024, timeout=3):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((self.ip, self.port))
s.settimeout(timeout)
if (username and password):
if (self.username and self.password):
s.send(self.username + "\r" + self.password + "\r")
s.send(command)
s.send(command.encode('utf-8'))
msg = s.recv(byte_size)
print(good + "Successfully sent '%s' to %s:%s" %
(str(command.strip()), self.ip, str(self.port)))
return msg
except socket.error:
print(bad + "Error sending '%s' to '%s' @ %s:%s" %
(str(command.strip()), self.name, self.ip, self.port))
# raise Exception("Error connecting to '%s' @ %s:%s" % (self.name, self.ip, self.port))
raise Exception("Error connecting to %s:%s" %
(self.ip, self.port))

def off(self):
return self.send_command("POWR0 \r")
Expand Down Expand Up @@ -155,8 +140,11 @@ def _check_ip(self):

if __name__ == "__main__":
# Example
# aquos = aquosTV("Basement TV", "192.168.1.12")
aquos = aquosTV("Test TV", "192.168.43.200")
# aquos = aquosTV("Basement TV", "192.168.1.2")
from time import sleep
aquos = aquosTV("192.168.1.2")
aquos.on()
sleep(1)
aquos.set_volume(30)
sleep(1)
aquos.off()
10 changes: 10 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# if [ -d "venv" ]; then
# source venv/bin/activate
# fi
#
python3 setup.py sdist bdist_wheel
python2 setup.py sdist bdist_wheel

pip install -r dev-requirements.txt --user

twine upload dist/*
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
twine
55 changes: 30 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,47 @@

here = path.abspath(path.dirname(__file__))

with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
long_description = f.read()

setup(
name='aquosRemote',
version='1.1.1',
description='A small Python module for sending Remote Control Codes to your Sharp AQUOS Smart TV',
name="aquosRemote",
version="1.3.1",
description="A small Python module for sending Remote Control Codes to your Sharp AQUOS Smart TV",
long_description=long_description,
url='https://github.com/thehappydinoa/aquosRemote',
author='Aidan Holland (thehappydinoa)',
author_email='[email protected]',
url="https://github.com/thehappydinoa/aquosRemote",
author="Aidan Holland (thehappydinoa)",
author_email="[email protected]",

keywords="aquos tv remote",

packages=find_packages(exclude=["contrib", "docs", "tests"]),

project_urls={
"Bug Reports": "https://github.com/thehappydinoa/aquosRemote/issues",
"Say Thanks!": "http://saythanks.io/to/thehappydinoa",
"Contribute!": "https://github.com/thehappydinoa/aquosRemote/pulls",
"Follow Me!": "https://twitter.com/thehappydinoa/",
},

classifiers=[
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 4 - Beta',
"Development Status :: 4 - Beta",

'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",

'License :: OSI Approved :: MIT License',
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",

'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],

keywords='aquos tv remote',

packages=find_packages(exclude=['contrib', 'docs', 'tests']),

project_urls={
'Bug Reports': 'https://github.com/thehappydinoa/aquosRemote/issues',
'Say Thanks!': 'http://saythanks.io/to/thehappydinoa',
'Contribute!': 'https://github.com/thehappydinoa/aquosRemote/pulls',
'Follow Me!': 'https://twitter.com/thehappydinoa/',
},
)

0 comments on commit f414eb1

Please sign in to comment.