-
Notifications
You must be signed in to change notification settings - Fork 19
setting up pycharm project for preimport script
craigmcchesney edited this page Mar 25, 2021
·
15 revisions
- create a directory for the github repo e.g.,
- mkdir /home/craig/cable-import
- change to that directory
- cd /home/craig/cable-import
- for convenience, create a directory here for input/output/config files
- mkdir /home/craig/cable-import/run
- move your existing folders configDir, inputDir, and outputDir to this run folder, so you'll have directories:
- /home/craig/cable-import/run/configDir (containing your existing ".conf" files"
- /home/craig/cable-import/run/inputDir (containing your input workbook xlsx files)
- /home/craig/cable-import/run/outputDir (directory where script output is generated)
- edit preimport.conf to change inputDir and outputDir to these new directories:
- [DEFAULT]
- inputDir = /home/craig/cable-import/run/inputDir
- outputDir = /home/craig/cable-import/run/outputDir
- change back to directory /home/craig/cable-import and clone the github repo:
- cd /home/craig/cable-import
- git clone https://github.com/craigmcchesney/ComponentDB.git
- location of import script is now /home/craig/cable-import/ComponentDB/tools/developer_tools/utilities/cable_import
- open pycharm, select "close project" from file menu to close existing project if any
- on pycharm window, select "create new project"
- in "New Project" dialog, click folder icon to right of "Location:" bar
- in "Select Base Directory" dialog, navigate to directory "/home/craig/cable-import/ComponentDB/tools/developer_tools/utilities/cable_import", selecting "cable_import" and click "OK"
- in "New Project" dialog, expand "Project Interpreter", select "Existing Interpreter", and select python 3.7
- click "OK" to create project
- accept dialog with message that directory is not empty, and to create project from existing sources
- open pycharm project settings (on linux, this is "Settings" on File menu, but on Mac it is "Project Preferences" or something along those lines
- expand "Project: cable_import" from left sidebar (in linux, maybe not necessary on mac)
- select "Project Interpreter" node under project and make sure python 3.7 is displayed
- select "Project Structure" node under project and add cdb python api
- in right sidebar, click "Add Content Root"
- navigate up two levels and back down to python-client (/home/craig/cable-import/ComponentDB/tools/developer_tools/python-client)
- select "python-client" folder and click "OK"
- click Apply/OK to close project settings
- in the left pycharm sidebar, you should now have a "cable_import" item with children "cable_import" and "python_client", and another item "External Libraries"
- run the script
- expand "cable_import" top-level item in left sidebar, expand child "cable_import", and select script "preImport.py"
- right click on "preImport.py" and select "Create preImport.py" with blue and yellow "+" shaped icon to its left to create a new "run configuration"
- in "Name" enter something like "IT CableType - Kabelbox"
- in "Parameters", enter "--configDir /home/craig/cable-import/run/configDir --type CableType --groupId IT --deploymentName KABELBOX"
- click "OK"
- click the run button (green right-pointing arrow in toolbar)
- script output should be displayed in "Run" console at bottom of pycharm window