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

Commit f71a979

Browse files
authored
Merge pull request #336 from akrithika27/feature/simplify_phx_imports
Cleanup phoenix files
2 parents 69484c6 + 55b1cd5 commit f71a979

File tree

16 files changed

+2416
-65
lines changed

16 files changed

+2416
-65
lines changed

src/test-apps/happy/bin/set_test_path.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
wrapper_dirs = [ ".",
4242
wrapper_home,
4343
wrapper_home + "/test-templates",
44+
wrapper_home + "/test-templates/generated",
4445
wrapper_home + "/lib",
4546
wrapper_home + "/bin" ]
4647

src/test-apps/happy/test-templates/ServiceAccountManager.py

Lines changed: 15 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env python
22

3-
4-
#
53
# Copyright (c) 2015-2017 Nest Labs, Inc.
64
# All rights reserved.
75
#
@@ -21,18 +19,16 @@
2119
#
2220
# @file
2321
# Implements generate register service cmd which is used to service provisioning
22+
# Note: "openweave-core/src/test-apps/happy/test-templates/generated"
23+
# needs to be added to PYTHONPATH
2424

2525
import json
26-
import os
27-
import requests
28-
import shutil
29-
import sys
30-
import tarfile
31-
import time
32-
26+
from httplib import HTTPSConnection
3327
import grpc
3428
from grpc.framework.interfaces.face.face import ExpirationError
35-
from httplib import HTTPSConnection
29+
import time
30+
import nestlabs.gateway.v2.gateway_api_pb2 as gateway_api_pb2
31+
import nestlabs.gateway.v2.gateway_api_pb2_grpc as gateway_api_pb2_grpc
3632

3733
options = {}
3834
options["tier"] = None
@@ -43,71 +39,25 @@
4339
def option():
4440
return options.copy()
4541

46-
47-
default_schema_branch = 'develop'
4842
apigw_fmt = 'apigw01.weave01.iad02.{tier}.nestlabs.com'
4943
apigw_siac_fmt = '{siac_name}.unstable.nestlabs.com'
5044

51-
phoenix_mirror_url = 'http://device-automation.nestlabs.com/phoenix-schema/python'
52-
53-
python_local = os.path.expanduser('~/.python-local')
54-
phoenix_cache = os.path.join(python_local, 'phoenix')
55-
56-
57-
def get_phoenix_hash(branch):
58-
url = '{}/{}/__latest__'.format(phoenix_mirror_url, branch)
59-
response = requests.get(url)
60-
response.raise_for_status()
61-
return response.text.rstrip()
62-
63-
_phoenix_proto_cache = dict()
64-
65-
66-
def get_phoenix_proto_dir(branch):
67-
if branch in _phoenix_proto_cache:
68-
return _phoenix_proto_cache.get(branch)
69-
70-
latest_hash = get_phoenix_hash(branch)
71-
tarball_dir = os.path.join(phoenix_cache, branch)
72-
tarball_path = os.path.join(tarball_dir, '{}.tar.gz'.format(latest_hash))
73-
extract_dir = os.path.join(tarball_dir, latest_hash)
74-
phoenix_dir = os.path.join(extract_dir, 'phoenix')
75-
if not os.path.exists(extract_dir):
76-
os.makedirs(extract_dir)
77-
78-
if not os.path.exists(tarball_path):
79-
url = '{}/{}/{}.tar.gz'.format(phoenix_mirror_url, branch, latest_hash)
80-
response = requests.get(url, stream=True)
81-
response.raise_for_status()
82-
with open(tarball_path, 'wb') as tarball_file:
83-
print type(response.raw)
84-
shutil.copyfileobj(response.raw, tarball_file)
85-
86-
if not os.path.exists(phoenix_dir):
87-
with tarfile.open(tarball_path) as tar:
88-
for member in tar.getmembers():
89-
if not member.isdir():
90-
tar.extract(member.path, path=extract_dir)
91-
92-
_phoenix_proto_cache[branch] = phoenix_dir
93-
return phoenix_dir
94-
95-
96-
def use_phoenix_schema(branch):
97-
sys.path.insert(0, get_phoenix_proto_dir(branch))
98-
9945

10046
class ServiceClient(object):
47+
"""
48+
Gets basic account information from Service
49+
Args:
50+
tier (str): tier of the service
51+
username (str): Account email/username
52+
password (str): Account password
53+
token (str): Account access token
54+
"""
10155

102-
def __init__(self, tier, username, password, token,
103-
schema_branch=default_schema_branch):
56+
def __init__(self, tier, username, password, token):
10457
self.tier = tier
10558
self.username = username
10659
self.password = password
10760

108-
use_phoenix_schema(schema_branch)
109-
import nestlabs.gateway.v2.gateway_api_pb2 as gateway_api_pb2
110-
import nestlabs.gateway.v2.gateway_api_pb2_grpc as gateway_api_pb2_grpc
11161
self.gateway_api_pb2 = gateway_api_pb2
11262
self.gateway_api_pb2_grpc = gateway_api_pb2_grpc
11363

src/test-apps/happy/test-templates/generated/__init__.py

Whitespace-only changes.

src/test-apps/happy/test-templates/generated/nest/__init__.py

Whitespace-only changes.

src/test-apps/happy/test-templates/generated/nest/messages/__init__.py

Whitespace-only changes.

src/test-apps/happy/test-templates/generated/nest/messages/schema_version_pb2.py

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

src/test-apps/happy/test-templates/generated/nestlabs/__init__.py

Whitespace-only changes.

src/test-apps/happy/test-templates/generated/nestlabs/gateway/__init__.py

Whitespace-only changes.

src/test-apps/happy/test-templates/generated/nestlabs/gateway/v1/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)