Last active
September 8, 2015 12:07
-
-
Save wehappyfew/306911b309a0816c7c83 to your computer and use it in GitHub Desktop.
The python project is in Jenkin's workspace folder. I want to run a python script on the QA server (Linux).The workspace folder's path must be added (on runtime for now) in the sys.path .That way I can make imports into the script from any module of the project. TODO->For a more permanent solution the path must be hardcoded in a var in the machine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'wehappyfew' | |
| import sys,os,pprint | |
| # check the sys.path before I add my directory | |
| print("1: -- ",sys.path) | |
| if os.name == "posix": # check if the script runs on Linux | |
| # If I comment it out, it will throw ImportError | |
| # This path should always be appended on runtime, | |
| # otherwise should be added on the server as ENVIRONMENTAL VARIABLE | |
| sys.path.append("/var/lib/jenkins/jobs/QA_Project/workspace/") | |
| # check the sys.path after I add my directory | |
| print pprint.pprint("2: -- ",sys.path) | |
| from TheProject import helpers #imports a simple var located to another file/module that prints "Hello world" | |
| print helpers.hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment