Skip to content

Commit

Permalink
Fix problems on Windows (#200)
Browse files Browse the repository at this point in the history
* fix windows issue caching schemas
* create a cookbook to develop on windows
  • Loading branch information
ffdarkpenguin authored and ricardoas committed Jan 23, 2018
1 parent 45919c7 commit de7ac81
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
5 changes: 4 additions & 1 deletion oneview_redfish_toolkit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ def store_schemas(schema_dir):
with open(path) as schema_file:
json_schema = json.load(schema_file)

file_name = path.split('/')[-1]
if os.name == 'nt':
file_name = path.split('\\')[-1]
else:
file_name = path.split('/')[-1]
stored_schemas["http://redfish.dmtf.org/schemas/v1/" + file_name] = \
json_schema

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ commands = {posargs}
commands = python setup.py test --coverage --testr-args='{posargs}'

[testenv:docs]
basepython=python3
basepython=python
deps=
sphinx
sphinx_rtd_theme
Expand Down
49 changes: 49 additions & 0 deletions window-dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Windows development environment setup

Follow the steps below to build a development environment on a Windows machine

* Install git
* Install python 3.5+ from python.org
* clone the project:

`git clone https://HewlettPackard/oneview-redfish-toolkit`
* Access project directory:

`cd oneview-redfish-toolkit`
* Create a virtual environment(venv):
`py -m venv .venv`

**NOTE:** `.venv` is the directory of the virtual environment. You can name it whatever you like, given it's not an existing directory in the project.
* Activate the virtual env:

`./venv/scripts/activate`

**NOTE:** this may trigger a security error. If you get an error regarding script policy you can pass that by issuing the command below:

`Set-ExecutionPolicy RemoteSigned -Scope CurrentUser`

**NOTE:** in `.\venv\Scripts\` there are 3 activation scripts.
* activate
* activate.bat
* activate.ps1

The `activate` script checks if you are using **Windows command prompt** (`cmd`) or **Windows PowerShell**. If the first it then calls `activate.bat` if the later it calls `activate.ps1`. It's been reported that calling `activate` on **Windows 7 does not activate** the virtual environment. If you have this problem please call the proper script for your shell. On Windows 10, activate worked fine on both, **command** and **powershell**

**NOTE:** to check inf you environment is active you will have`(.venv)` prepended to your prompt. The prepended string will be whatever you named you virtual env directory. See a example below:

`(.venv)C:\MyProjects\oneview-redfish-toolkit> `

* Install the project and dependencies in the venv

`pip install -e .`
* Edit the configuration file `redfish.conf` and setup the OneView credentials
* Starting the service:

`./run.cmd`
* Runinng tests

`py -m unittest`
* Runing pep8 check

`py -m flake8`

0 comments on commit de7ac81

Please sign in to comment.