Skip to content

Commit

Permalink
[qalab] added drivers, moved binaries directory
Browse files Browse the repository at this point in the history
  • Loading branch information
netzulo committed Aug 21, 2017
1 parent 0d5a0b1 commit bff6aa0
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 26 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
## Command Usage

```
usage: qalab.py [-h] [-v] {install} ...
usage: qalab.py [-h] [-v] {selenium} ...
Performs selenium drivers operations
positional arguments:
{install} Install command
install Install selenium HUB or NODE
{selenium} Actions for selenium instance
selenium Actions for selenium HUB or NODE
selenium arguments:
-h, --help show this help message and exit
-m MODE, --mode MODE Select mode, values are: [hub, node]
-i, --install Download selenium jar
-s, --start Start Selenium jar
optional arguments:
-h, --help show this help message and exit
Expand Down
9 changes: 5 additions & 4 deletions qalab.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,23 @@
<Content Include="LICENSE" />
<Content Include="qalab\configs\settings.hub.example.json" />
<Content Include="qalab\configs\settings.node.example.json" />
<Content Include="qalab\drivers\chromedriver_32" />
<Content Include="qalab\drivers\chromedriver_32.exe" />
<Content Include="qalab\drivers\chromedriver_64" />
<Content Include="README.md" />
</ItemGroup>
<ItemGroup>
<Folder Include="bin\" />
<Folder Include="logs\" />
<Folder Include="qalab\" />
<Folder Include="qalab\configs\" />
<Folder Include="qalab\drivers\" />
</ItemGroup>
<ItemGroup>
<Compile Include="bin\__init__.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="logs\__init__.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="qalab\configs\__init__.py" />
<Compile Include="qalab\drivers\__init__.py" />
<Compile Include="qalab\qalab.py">
<SubType>Code</SubType>
</Compile>
Expand Down
Binary file added qalab/drivers/EdgeDriver_14393.exe
Binary file not shown.
Binary file added qalab/drivers/EdgeDriver_15063.exe
Binary file not shown.
Binary file added qalab/drivers/EdgeDriver_64.exe
Binary file not shown.
Binary file added qalab/drivers/IEDriverServer_32.exe
Binary file not shown.
Binary file added qalab/drivers/IEDriverServer_64.exe
Binary file not shown.
File renamed without changes.
Binary file added qalab/drivers/chromedriver_32.exe
Binary file not shown.
Binary file added qalab/drivers/chromedriver_64
Binary file not shown.
Binary file added qalab/drivers/geckodriver_64
Binary file not shown.
Binary file added qalab/drivers/geckodriver_64.exe
Binary file not shown.
Binary file added qalab/drivers/phantomjs.exe
Binary file not shown.
78 changes: 59 additions & 19 deletions qalab/qalab.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#! /usr/bin/env python
import argparse, logging, logging.handlers, os, shutil, wget
import argparse, logging, logging.handlers, os, shutil, wget, subprocess

logger = logging.getLogger('qalab')
logger.setLevel(logging.DEBUG)
if not os.path.exists('../logs'): os.mkdir('../logs')
log_file_handler = logging.handlers.TimedRotatingFileHandler('../logs/qalab.log', when='M', interval=2)
if not os.path.exists('logs'): os.mkdir('logs')
log_file_handler = logging.handlers.TimedRotatingFileHandler('logs/qalab.log', when='M', interval=2)
log_file_handler.setFormatter( logging.Formatter('%(asctime)s [%(levelname)s](%(name)s:%(funcName)s:%(lineno)d): %(message)s') )
log_file_handler.setLevel(logging.DEBUG)
logger.addHandler(log_file_handler)
Expand All @@ -21,9 +21,13 @@
## Main args
parser.add_argument('-v', '--verbose', action="count", help="verbose level... repeat up to three times.")
## Args with subs
commands = parser.add_subparsers(dest='install', help="Install selenium instance")
command_install = commands.add_parser("install", help="Install selenium HUB or NODE")
command_install.add_argument('--mode', default=None, help="Select installation mode", metavar="hub, node")
commands = parser.add_subparsers(dest="selenium", help="Actions for selenium instance")
command_install = commands.add_parser("selenium", help="Actions for selenium HUB or NODE")
command_install.add_argument('-m','--mode', default=None, help="Select mode, values are: [hub, node]")
command_install.add_argument('-i','--install', action="store_true", help="Download selenium jar")
command_install.add_argument('-s','--start', action="store_true", help="Start Selenium jar")
command_install.add_argument('-p','--platform', default=None, help="Select mode, values are: [lin32,lin64,win32,win64]")



def handle_command_install(args):
Expand All @@ -34,21 +38,57 @@ def handle_command_install(args):
selenium_url = "{}/{}/{}".format(selenium_url_base,
selenium_url_version,
selenium_jar)
config_src = "../configs/settings.{}.example.json".format(args.mode)
config_dst = "../configs/settings.{}.json".format(args.mode)
config_src = "qalab/configs/settings.{}.example.json".format(args.mode)
config_dst = "qalab/configs/settings.{}.json".format(args.mode)
platforms = ["win32", "win64","lin32","lin64"]

if args.mode is None:
logger.error("Can't start installation without select available mode")
return # TODO: hate return like this , must improve
logger.error("Can't start without select available mode: [hub, node]")
return
else:
logger.info("Downloading selenium from : {}".format(selenium_url))
selenium_file = wget.download(selenium_url, "../bin")
logger.info("Installation : {}, copying configuration file from example".format(args.mode))
shutil.copy2(config_src , config_dst) # TODO: FAILED, fix me , please



logger.error("PROCESS NOT IMPLEMENTED")
if args.install:
logger.info("Downloading selenium from : {}".format(selenium_url))
selenium_file = wget.download(selenium_url, "qalab/drivers")
logger.info("Installation : {}, copying configuration file from example".format(args.mode))
shutil.copy2(config_src , config_dst)
logger.info("Installacion : COMPLETED")
elif args.start:
cmd_drivers = []
if args.platform is not None and args.platform not in platforms:
logger.error("Can't start without select available platform: [win32,win64,lin32,lin64]")
return
elif args.platform == "win32":
cmd_drivers.extend(["-Dwebdriver.chrome.driver=qalab/drivers/chromedriver_32.exe",
"-Dwebdriver.gecko.driver=qalab/drivers/geckodriver_64.exe",
"-Dwebdriver.ie.driver=qalab/drivers/IEDriverServer_32.exe",
"-Dwebdriver.edge.driver==qalab/drivers/EdgeDriver_64.exe",
"-Dphantomjs.binary.path=qalab/drivers/phantomjs.exe"])
elif args.platform == "win64":
cmd_drivers.extend(["-Dwebdriver.chrome.driver=qalab/drivers/chromedriver_32.exe",
"-Dwebdriver.gecko.driver=qalab/drivers/geckodriver_64.exe",
"-Dwebdriver.ie.driver=qalab/drivers/IEDriverServer_64.exe",
"-Dwebdriver.edge.driver==qalab/drivers/EdgeDriver_64.exe",
"-Dphantomjs.binary.path=qalab/drivers/phantomjs.exe"])
elif args.platform == "lin32":
cmd_drivers.extend(["-Dwebdriver.chrome.driver=qalab/drivers/chromedriver_64",
"-Dwebdriver.gecko.driver=qalab/drivers/geckodriver_64",
"-Dphantomjs.binary.path=qalab/drivers/phantomjs"])
elif args.platform == "lin64":
cmd_drivers.extend(["-Dwebdriver.chrome.driver=qalab/drivers/chromedriver_64",
"-Dwebdriver.gecko.driver=qalab/drivers/geckodriver_64",
"-Dphantomjs.binary.path=qalab/drivers/phantomjs"])
# TODO: adapt this array to use on win/lin 32/64
cmd_args = ["java"]
if args.mode == "node":
cmd_args.extend(cmd_drivers)
cmd_args.extend(["-jar", "qalab/drivers/{}".format(selenium_jar),
"-role", args.mode, "-{}Config".format(args.mode), config_dst,
"-log","logs/selenium.{}.log".format(args.mode)]
)
subprocess.call(cmd_args)
pass
else:
logger.error("ACTION not selected: --install , --start")


def set_log_level_from_verbose(args):
Expand All @@ -67,7 +107,7 @@ def set_log_level_from_verbose(args):
if __name__ == '__main__':
args = parser.parse_args()
set_log_level_from_verbose(args)
if args.install == 'install':
if args.selenium == 'selenium':
handle_command_install(args)
else:
logger.error("Unknown command: {}".format(args))

0 comments on commit bff6aa0

Please sign in to comment.