Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekmo committed Jul 31, 2019
2 parents 54fc0bb + 094708a commit e04841e
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.3.2
current_version = 1.3.3
commit = True
tag = True

Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ RUN apk update \
procps=3.3.15-r0 \
tcpdump=4.9.2-r3 \
scapy=2.4.0-r0 \
&& apk add --no-cache \
bash \
&& pip install --no-cache-dir -r py3-requirements.txt \
&& pip install . \
&& python -m amazon_dash.install \
Expand Down
12 changes: 8 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ with few resources.

.. code:: console
$ sudo pip install amazon-dash # and after:
$ sudo python -m amazon_dash.install
$ sudo pip3 install amazon-dash # and after:
$ sudo python3 -m amazon_dash.install
Also available on `AUR <https://aur.archlinux.org/packages/amazon-dash-git/>`_ and
`FreeNAS <http://docs.nekmo.org/amazon-dash/installation.html#freenas>`_. See other installation methods
`in the documentation <http://docs.nekmo.org/amazon-dash/installation.html>`_.
`FreeNAS <http://docs.nekmo.org/amazon-dash/installation.html#freenas>`_. You can also use ``pip2`` and
``python2`` if your system only has Python2, but Python 3 is the recommended version. See other installation
methods `in the documentation <http://docs.nekmo.org/amazon-dash/installation.html>`_.

**Note:** ``scapy 2.4.1/2.4.2`` releases are broken (``MANIFEST`` is missing in wheel). Scapy 2.4.0 will be used by
default (or earlier). It may also be necessary to install ``tcpdump`` on your system (in Debian
``apt install tcpdump``).

2. Use *discovery mode* **to know the mac of your Dash** (Run the program, and then press any button):

Expand Down
2 changes: 1 addition & 1 deletion amazon_dash/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

__version__ = '1.3.2'
__version__ = '1.3.3'
8 changes: 5 additions & 3 deletions amazon_dash/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def execute(self, root_allowed=False):
if self.data.get('content-type'):
kwargs['headers']['content-type'] = self.data['content-type']
if self.data.get('body'):
kwargs['data'] = self.data['body']
kwargs['data'] = self.data['body'].encode('utf-8')
if self.data.get('auth'):
kwargs['auth'] = tuple(self.data['auth'].split(':', 1))
try:
Expand Down Expand Up @@ -278,7 +278,9 @@ def get_headers(self):
:return: HTTP Headers
:rtype: dict
"""
return copy.copy(self.default_headers or {})
headers = copy.copy(self.default_headers or {})
headers.update(self.data.get('headers') or {})
return headers

def get_body(self):
"""Get body to send. By default default_body
Expand Down Expand Up @@ -363,7 +365,7 @@ class ExecuteOpenHab(ExecuteOwnApiBase):

def __init__(self, name, data):
super(ExecuteOpenHab, self).__init__(name, data)
self.data['headers'] = {'Accept': 'application/json'}
self.data['headers'] = dict(self.data.get('headers') or {}, **{'Accept': 'application/json'})

def get_url(self):
"""Open Hab url
Expand Down
8 changes: 8 additions & 0 deletions amazon_dash/install/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import platform
import shutil
import sys
from subprocess import check_output
Expand All @@ -15,6 +16,7 @@
dirname = os.path.dirname(os.path.abspath(__file__))
CONFIG_EXAMPLE = os.path.join(dirname, 'amazon-dash.yml')
SYSTEMD_SERVICE = os.path.join(dirname, 'services', 'amazon-dash.service')
UNSUPPORTED_SYSTEMS = ['Darwin', 'Windows']


if sys.version_info < (3,0):
Expand Down Expand Up @@ -125,6 +127,12 @@ def installation(self):
@click.group(cls=DefaultGroup, default='all', default_if_no_args=True)
@click.option('--root-required/--root-not-required', default=True)
def cli(root_required):
system = platform.system()
if system in UNSUPPORTED_SYSTEMS:
click.echo('{} is not supported by the installation wizard. '
'However, you can use Amazon-dash manually.\n'
'http://docs.nekmo.org/amazon-dash/usage.html#manually'.format(system), err=True)
sys.exit(2)
if os.getuid() and root_required:
click.echo('The installation must be done as root. Maybe you forgot sudo?', err=True)
sys.exit(1)
Expand Down
2 changes: 2 additions & 0 deletions amazon_dash/install/services/amazon-dash.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[Unit]
Description=Amazon Dash service
After=network-online.target
Wants=network-online.target

[Service]
User=root
Expand Down
2 changes: 1 addition & 1 deletion common-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PyYAML>=3.0
jsonschema
jsonschema<3.0.0
requests
click
click-default-group
14 changes: 11 additions & 3 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ To install amazon-dash, run these commands in your terminal:

.. code-block:: console
$ pip install -U amazon_dash
$ sudo python -m amazon_dash.install
$ sudo pip3 install -U amazon_dash
$ sudo python3 -m amazon_dash.install
This is the preferred method to install amazon-dash, as it will always install the most recent stable release.
You must execute both commands in the correct order.
You must execute both commands in the correct order. Amazon-dash also works with Python2:

.. code-block:: console
$ sudo pip2 install -U amazon_dash
$ sudo python2 -m amazon_dash.install
If you don't have `pip`_ installed, this `Python installation guide`_ can guide
you through the process.
Expand Down Expand Up @@ -62,6 +67,9 @@ There is support for FreeNAS created by `Troy Prelog <https://github.com/tprelog
wget -O /tmp/amazon-dash.json https://raw.githubusercontent.com/tprelog/iocage-amazon-dash/master/amazon-dash.json
sudo iocage fetch -P dhcp=on vnet=on bpf=yes -n /tmp/amazon-dash.json --branch 'master'

**IMPORTANT**: ``scapy >= 2.4.1`` (including 2.4.2)
`has a bug with FreeBSD <https://github.com/secdev/scapy/issues/1793>`_. Install Scapy 2.4.0


Installation Issues
-------------------
Expand Down
2 changes: 1 addition & 1 deletion py2-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scapy
scapy<=2.4.0
subprocess32
-r common-requirements.txt
2 changes: 1 addition & 1 deletion py3-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scapy>=2.4.0
scapy<=2.4.0
-r common-requirements.txt
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Package description
"""Hack your Amazon Dash to run what you want.
"""
from setuptools import setup, find_packages, __version__ as setuptool_version
from distutils.util import convert_path
Expand Down

0 comments on commit e04841e

Please sign in to comment.