diff --git a/.gitignore b/.gitignore index 0b26d82..aefa28c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ +__pychache__/ *.pyc build/ dist/ aquosRemote.egg-info/ +venv/ diff --git a/README.rst b/README.rst index d6707c0..2b5559c 100644 --- a/README.rst +++ b/README.rst @@ -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 @@ -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 ------- diff --git a/aquosRemote/__init__.py b/aquosRemote/__init__.py index 01578c2..e69de29 100644 --- a/aquosRemote/__init__.py +++ b/aquosRemote/__init__.py @@ -1 +0,0 @@ -from aquos import * diff --git a/aquosRemote/aquos.py b/aquosRemote/aquos.py index 87fbe01..df18eba 100644 --- a/aquosRemote/aquos.py +++ b/aquosRemote/aquos.py @@ -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") @@ -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() diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..167a565 --- /dev/null +++ b/deploy.sh @@ -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/* diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 0000000..af996cf --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1 @@ +twine diff --git a/setup.py b/setup.py index 59657a0..8d82311 100644 --- a/setup.py +++ b/setup.py @@ -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='thehappydinoa@gmail.com', + url="https://github.com/thehappydinoa/aquosRemote", + author="Aidan Holland (thehappydinoa)", + author_email="thehappydinoa@gmail.com", + + 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/', - }, )