Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding source as binding platform + version for tracing through the i… #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions browserstack/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import browserstack.version

# Python modules report to module_name.__version__ with their version
# Ref: https://www.python.org/dev/peps/pep-0008/#module-level-dunder-names
# With this, browserstack.__version__ will respond with <version>

__version__ = version.__version__
12 changes: 11 additions & 1 deletion browserstack/local.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import subprocess, os, time, json, psutil
import browserstack.version
from browserstack.local_binary import LocalBinary
from browserstack.bserrors import BrowserStackLocalError


# Python modules report to module_name.__version__ with their version
# Ref: https://www.python.org/dev/peps/pep-0008/#module-level-dunder-names
# With this, browserstack.local.__version__ will respond with <version>
__version__ = browserstack.version.__version__

class Local:
def __init__(self, key=None, binary_path=None, **kwargs):
self.key = os.environ['BROWSERSTACK_ACCESS_KEY'] if 'BROWSERSTACK_ACCESS_KEY' in os.environ else key
Expand All @@ -16,8 +23,11 @@ def __xstr(self, key, value):
else:
return ['-' + key, value]

def _get_version(self):
return __version__

def _generate_cmd(self):
cmd = [self.binary_path, '-d', 'start', '-logFile', self.local_logfile_path, self.key]
cmd = [self.binary_path, '-d', 'start','--source', 'python-' + self._get_version() , '-logFile', self.local_logfile_path, self.key]
for o in self.options.keys():
if self.options.get(o) is not None:
cmd = cmd + self.__xstr(o, self.options.get(o))
Expand Down
1 change: 1 addition & 0 deletions browserstack/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.2.3"
13 changes: 12 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@


# Need to read the single-source-of-truth version file as text
# Importing version_file here can open the door to a cyclic dependency
def get_version(a_path):
with open(a_path, 'r') as version_file:
for a_line in version_file:
if '__version__' in a_line:
# Cleaning up all spaces and quotes around a string of the form __version__ = "x.y.z"
return a_line.split("=")[1].split()[0].replace('"', '').replace("'","")
raise RuntimeError("Unable to find version string.")
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(
name = 'browserstack-local',
packages = ['browserstack'],
version = '1.2.2',
version = get_version("browserstack/version.py"),
description = 'Python bindings for Browserstack Local',
author = 'BrowserStack',
author_email = '[email protected]',
Expand Down
3 changes: 3 additions & 0 deletions tests/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def test_multiple(self):
except BrowserStackLocalError as e:
self.assertEqual(str(e), "Either another browserstack local client is running on your machine or some server is listening on port 45691")

def test_version(self):
self.assertEqual("1.2.3", self.local._get_version())

def test_verbose(self):
self.local.start(v=True, onlyCommand=True)
self.assertIn('-v', self.local._generate_cmd())
Expand Down