Skip to content
This repository was archived by the owner on Dec 14, 2021. It is now read-only.

Commit 231d99e

Browse files
author
Eric Gourlaouen
committed
all: Fix package import
1 parent dccb17a commit 231d99e

File tree

92 files changed

+77
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+77
-85
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ before_script:
1717
- docker run -d -p 127.0.0.1:1883:1883 thethingsnetwork/rabbitmq
1818

1919
script:
20-
- pycodestyle --first ttn
21-
- pycodestyle --first utils
20+
- pycodestyle --first ttn/*.py
21+
- pycodestyle --first ttn/utils
2222
- pytest test_*.py
2323

2424
before_deploy:

mock.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
# MIT license that can be found in the LICENSE file.
55

66

7-
import github_com.TheThingsNetwork.api.handler.handler_pb2 as proto
8-
import github_com.TheThingsNetwork.api.protocol.lorawan.device_pb2 as lorawan
9-
import github_com.TheThingsNetwork.api.handler.handler_pb2_grpc as handler
7+
8+
import ttn.github_com.TheThingsNetwork.api.handler.handler_pb2 as proto
109

1110

1211
class MockApplicationManager:

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@
33
# Use of this source code is governed by the
44
# MIT license that can be found in the LICENSE file.
55

6-
from setuptools import setup
6+
from setuptools import find_packages, setup
77

88
import io
99

1010
with io.open("README.rst", encoding="utf-8") as f:
1111
long_description = f.read()
1212

1313
setup(name="ttn",
14-
version="2.1.0",
14+
version="2.1.1",
1515
description="The Things Network Client",
1616
long_description = long_description,
1717
url = "https://github.com/TheThingsNetwork/python-app-sdk",
1818
author="Emmanuelle Lejeail",
1919
author_email="[email protected]",
2020
license="MIT",
21-
packages=["ttn", "github_com", "utils"],
21+
packages=find_packages(),
2222
install_requires=[
2323
"paho-mqtt",
2424
"events",
2525
"grpcio",
26+
"python-jose",
2627
# packages which need to be imported to make gRPC work
2728
"protobuf",
2829
"google-api-python-client",

test_application.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
import unittest
88
from mock import MockApplicationManager
99
from ttn import ApplicationClient
10-
import github_com.TheThingsNetwork.api.handler.handler_pb2 as handler
11-
import github_com.TheThingsNetwork.api.protocol.lorawan.device_pb2 as lorawan
12-
from utils import stubs
10+
import ttn.github_com.TheThingsNetwork.api.handler.handler_pb2 as handler
11+
from ttn.utils import stubs
1312
import binascii
1413

1514

test_discovery.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import unittest
77
from ttn import DiscoveryClient
8-
from utils import stubs
98

109
class TestDiscoveryClient(unittest.TestCase):
1110

test_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
import unittest
88
import ttn
9-
import time
10-
from utils import stubs
9+
from ttn.utils import stubs
1110

1211
class TestHandlerClient(unittest.TestCase):
1312

test_ttnmqtt.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
# MIT license that can be found in the LICENSE file.
55

66
import unittest
7-
import os
87
import time
98
import json
109
from ttn import MQTTClient as mqtt
11-
from utils import stubs
10+
from ttn.utils import stubs
1211

1312
MQTT_ADDR = "localhost:1883"
1413

ttn/application.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
import grpc
88
import os
99
import base64
10-
import json
11-
import github_com.TheThingsNetwork.api.handler.handler_pb2 as proto
12-
import github_com.TheThingsNetwork.api.protocol.lorawan.device_pb2 as lorawan
13-
import github_com.TheThingsNetwork.api.handler.handler_pb2_grpc as handler
1410

1511

16-
from jose import jwt
12+
import ttn.github_com.TheThingsNetwork.api.handler.handler_pb2 as proto
13+
import ttn.github_com.TheThingsNetwork.api.protocol.lorawan.device_pb2 \
14+
as lorawan
15+
import ttn.github_com.TheThingsNetwork.api.handler.handler_pb2_grpc as handler
16+
from ttn.utils import stubs
17+
1718
from .discovery import DiscoveryClient
18-
from utils import read_key, stubs
1919

2020

2121
if os.getenv("GRPC_SSL_CIPHER_SUITES"):
@@ -38,13 +38,13 @@ def __init__(self, app_id, access_key,
3838

3939
if not net_address:
4040
discovery = DiscoveryClient(discovery_address)
41-
announcement = discovery.get_by_app_id(self.app_id)
41+
announcement = discovery.get_by_app_id(self.app_id.encode())
4242
net_address = announcement.net_address
4343
cert_content = announcement.certificate
4444
elif not cert_content:
4545
raise RuntimeError("You need to provide credentials")
4646

47-
creds = grpc.ssl_channel_credentials(cert_content)
47+
creds = grpc.ssl_channel_credentials(cert_content.encode())
4848
channel = grpc.secure_channel(net_address, creds)
4949
self.client = handler.ApplicationManagerStub(channel)
5050

@@ -53,7 +53,7 @@ def __create_metadata(self):
5353

5454
def get(self):
5555
req = proto.ApplicationIdentifier()
56-
req.app_id = self.app_id
56+
req.app_id = self.app_id.encode()
5757
meta = self.__create_metadata()
5858
try:
5959
app = self.client.GetApplication(req, TIME_OUT, meta)

ttn/discovery.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
# MIT license that can be found in the LICENSE file.
55

66

7-
import github_com.TheThingsNetwork.api.discovery.discovery_pb2_grpc as disco
8-
import github_com.TheThingsNetwork.api.discovery.discovery_pb2 as proto
7+
import ttn.github_com.TheThingsNetwork.api.discovery.discovery_pb2_grpc \
8+
as disco
9+
import ttn.github_com.TheThingsNetwork.api.discovery.discovery_pb2 as proto
910

1011
import grpc
1112
import os
12-
from utils import stubs
13+
from ttn.utils import stubs
1314

1415
if os.getenv("GRPC_SSL_CIPHER_SUITES"):
1516
os.environ["GRPC_SSL_CIPHER_SUITES"] += os.pathsep + stubs.MODERN_CIPHER

github_com/TheThingsNetwork/api/broker/broker_pb2.py renamed to ttn/github_com/TheThingsNetwork/api/broker/broker_pb2.py

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github_com/TheThingsNetwork/api/broker/broker_pb2_grpc.py renamed to ttn/github_com/TheThingsNetwork/api/broker/broker_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
import grpc
33

4-
from github_com.TheThingsNetwork.api.broker import broker_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_broker_dot_broker__pb2
4+
from ttn.github_com.TheThingsNetwork.api.broker import broker_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_broker_dot_broker__pb2
55
from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
66

77

github_com/TheThingsNetwork/api/discovery/discovery_pb2.py renamed to ttn/github_com/TheThingsNetwork/api/discovery/discovery_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github_com/TheThingsNetwork/api/discovery/discovery_pb2_grpc.py renamed to ttn/github_com/TheThingsNetwork/api/discovery/discovery_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
import grpc
33

4-
from github_com.TheThingsNetwork.api.discovery import discovery_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_discovery_dot_discovery__pb2
4+
from ttn.github_com.TheThingsNetwork.api.discovery import discovery_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_discovery_dot_discovery__pb2
55
from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
66

77

github_com/TheThingsNetwork/api/gateway/gateway_pb2.py renamed to ttn/github_com/TheThingsNetwork/api/gateway/gateway_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github_com/TheThingsNetwork/api/handler/handler_pb2.py renamed to ttn/github_com/TheThingsNetwork/api/handler/handler_pb2.py

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github_com/TheThingsNetwork/api/handler/handler_pb2_grpc.py renamed to ttn/github_com/TheThingsNetwork/api/handler/handler_pb2_grpc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
import grpc
33

4-
from github_com.TheThingsNetwork.api.broker import broker_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_broker_dot_broker__pb2
5-
from github_com.TheThingsNetwork.api.handler import handler_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_handler_dot_handler__pb2
4+
from ttn.github_com.TheThingsNetwork.api.broker import broker_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_broker_dot_broker__pb2
5+
from ttn.github_com.TheThingsNetwork.api.handler import handler_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_handler_dot_handler__pb2
66
from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
77

88

github_com/TheThingsNetwork/api/monitor/monitor_pb2.py renamed to ttn/github_com/TheThingsNetwork/api/monitor/monitor_pb2.py

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github_com/TheThingsNetwork/api/monitor/monitor_pb2_grpc.py renamed to ttn/github_com/TheThingsNetwork/api/monitor/monitor_pb2_grpc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
import grpc
33

4-
from github_com.TheThingsNetwork.api.broker import broker_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_broker_dot_broker__pb2
5-
from github_com.TheThingsNetwork.api.gateway import gateway_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_gateway_dot_gateway__pb2
6-
from github_com.TheThingsNetwork.api.handler import handler_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_handler_dot_handler__pb2
7-
from github_com.TheThingsNetwork.api.networkserver import networkserver_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_networkserver_dot_networkserver__pb2
8-
from github_com.TheThingsNetwork.api.router import router_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_router_dot_router__pb2
4+
from ttn.github_com.TheThingsNetwork.api.broker import broker_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_broker_dot_broker__pb2
5+
from ttn.github_com.TheThingsNetwork.api.gateway import gateway_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_gateway_dot_gateway__pb2
6+
from ttn.github_com.TheThingsNetwork.api.handler import handler_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_handler_dot_handler__pb2
7+
from ttn.github_com.TheThingsNetwork.api.networkserver import networkserver_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_networkserver_dot_networkserver__pb2
8+
from ttn.github_com.TheThingsNetwork.api.router import router_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_router_dot_router__pb2
99
from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
1010

1111

github_com/TheThingsNetwork/api/networkserver/networkserver_pb2.py renamed to ttn/github_com/TheThingsNetwork/api/networkserver/networkserver_pb2.py

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github_com/TheThingsNetwork/api/networkserver/networkserver_pb2_grpc.py renamed to ttn/github_com/TheThingsNetwork/api/networkserver/networkserver_pb2_grpc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
import grpc
33

4-
from github_com.TheThingsNetwork.api.broker import broker_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_broker_dot_broker__pb2
5-
from github_com.TheThingsNetwork.api.handler import handler_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_handler_dot_handler__pb2
6-
from github_com.TheThingsNetwork.api.networkserver import networkserver_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_networkserver_dot_networkserver__pb2
4+
from ttn.github_com.TheThingsNetwork.api.broker import broker_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_broker_dot_broker__pb2
5+
from ttn.github_com.TheThingsNetwork.api.handler import handler_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_handler_dot_handler__pb2
6+
from ttn.github_com.TheThingsNetwork.api.networkserver import networkserver_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_networkserver_dot_networkserver__pb2
77

88

99
class NetworkServerStub(object):

github_com/TheThingsNetwork/api/protocol/lorawan/device_address_pb2.py renamed to ttn/github_com/TheThingsNetwork/api/protocol/lorawan/device_address_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github_com/TheThingsNetwork/api/protocol/lorawan/device_address_pb2_grpc.py renamed to ttn/github_com/TheThingsNetwork/api/protocol/lorawan/device_address_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
import grpc
33

4-
from github_com.TheThingsNetwork.api.protocol.lorawan import device_address_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_protocol_dot_lorawan_dot_device__address__pb2
4+
from ttn.github_com.TheThingsNetwork.api.protocol.lorawan import device_address_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_protocol_dot_lorawan_dot_device__address__pb2
55

66

77
class DevAddrManagerStub(object):

github_com/TheThingsNetwork/api/protocol/lorawan/device_pb2.py renamed to ttn/github_com/TheThingsNetwork/api/protocol/lorawan/device_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github_com/TheThingsNetwork/api/protocol/lorawan/device_pb2_grpc.py renamed to ttn/github_com/TheThingsNetwork/api/protocol/lorawan/device_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
import grpc
33

4-
from github_com.TheThingsNetwork.api.protocol.lorawan import device_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_protocol_dot_lorawan_dot_device__pb2
4+
from ttn.github_com.TheThingsNetwork.api.protocol.lorawan import device_pb2 as github__com_dot_TheThingsNetwork_dot_api_dot_protocol_dot_lorawan_dot_device__pb2
55
from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
66

77

github_com/TheThingsNetwork/api/protocol/lorawan/lorawan_pb2.py renamed to ttn/github_com/TheThingsNetwork/api/protocol/lorawan/lorawan_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github_com/TheThingsNetwork/api/protocol/protocol_pb2.py renamed to ttn/github_com/TheThingsNetwork/api/protocol/protocol_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)