Skip to content

Commit

Permalink
Reintroduce support for configuring a single node via the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
davehunt committed Sep 11, 2012
1 parent 720676c commit 0c1a102
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Change Log
* Improved console output
* Skip registering nodes that are already registered
* Allow forcing of nodes that are already registered
* Reintroduced support for configuring a single node via the command line

0.2
---
Expand Down
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,42 @@ From source:
Running FlynnID
---------------

FlynnID requires a configuration file in JSON format to be specified on the command line.
FlynnID requires either a configuration file in JSON format or command line arguments. Using a configuration
file allows for registration of one or more multiple nodes, whereas the command line arguments only allow for
registration of a single node.

For full usage details run the following command:

$ flynnid --help

--version show program's version number and exit
-h, --help show this help message and exit
-v, --verbose increase verbosity
--force force registration of nodes
Usage: flynnid config [options]

### Example configuration
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-v, --verbose increase verbosity
--force force registration of node(s)
--hubhost=str host selenium grid is listening on [default: localhost]
--hubport=num port selenium grid is listening on [default: 4444]
--nodeconfig=path configuration file for nodes to register.
--nodehost=str host selenium node is listening on [default: localhost]
--nodeport=num port selenium node is listening on [default: 5555]
--browsername=str name of browser available on node
--browserver=str version of browser available on node
--platform=str platform of node

### Example: Registering a single node from the command line

flynnid --nodeport=8080 --browsername=android --browserver=2.3.3 --platform=ANDROID

### Example: Registering multiple nodes from a configuration file

The following would register two AndroidDriver nodes on a local Selenium Grid hub:

flynnid config.json

Where config.json contains:

{
"hub": {
"host": "localhost",
Expand Down
76 changes: 69 additions & 7 deletions flynnid/flynnid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,86 @@
import urllib2

def main ():
usage = "Usage: %prog [options] config"
usage = "Usage: %prog config [options]"
parser = OptionParser(usage=usage, version='%prog 0.3')
parser.set_defaults(verbose=False)
parser.add_option('-v', '--verbose',
action='store_true',
help='increase verbosity')
parser.add_option('--force',
action='store_true',
help='force registration of nodes')
help='force registration of node(s)')
parser.add_option('--hubhost',
action='store',
type='string',
metavar='str',
dest='hub_host',
default='localhost',
help='host selenium grid is listening on [default: %default]')
parser.add_option('--hubport',
action='store',
type='int',
metavar='num',
dest='hub_port',
default=4444,
help='port selenium grid is listening on [default: %default]')
parser.add_option('--nodeconfig',
action='store',
type='string',
metavar='path',
dest='node_config',
help='configuration file for nodes to register.')
parser.add_option('--nodehost',
action='store',
type='string',
metavar='str',
dest='node_host',
default='localhost',
help='host selenium node is listening on [default: %default]')
parser.add_option('--nodeport',
action='store',
type='int',
metavar='num',
dest='node_port',
default=5555,
help='port selenium node is listening on [default: %default]')
parser.add_option('--browsername',
action='store',
type='str',
metavar='str',
dest='browser_name',
help='name of browser available on node')
parser.add_option('--browserver',
action='store',
type='str',
metavar='str',
dest='browser_version',
help='version of browser available on node')
parser.add_option('--platform',
action='store',
type='str',
metavar='str',
help='platform of node')
(options, args) = parser.parse_args()

if len(args) < 1:
sys.exit('ERROR: Configuration file not specified!')
if len(args) == 1:

if not os.path.exists(args[0]):
sys.exit('ERROR: Configuration file %s not found!' % args[0])
if not os.path.exists(args[0]):
sys.exit('ERROR: Configuration file %s not found!' % args[0])

config = json.load(open(args[0]))
config = json.load(open(args[0]))
else:
config = {
"hub":{
"host":options.hub_host,
"port":options.hub_port},
"nodes":[{
"host":options.node_host,
"port":options.node_port,
"browser": {
"name":options.browser_name,
"version":options.browser_version},
"platform":options.platform}]}

hub_host = config['hub']['host']
hub_port = config['hub']['port']
Expand Down

0 comments on commit 0c1a102

Please sign in to comment.