5.3 Running Scripts

Scripts can be invoked in several different ways depending on your needs.

  • Command line.
  • Python Shell.
  • Navigator Menu.
  • Script Server.

5.3.1 Command Line Invocation

Scripts can run unattended from the command line when desired, assuming you have not added any dynamic prompts to your script. To invoke a script from the command go to your system’s command window and start the program with the script option like this, ChemTree -s script.py. This will run the contents of script.py.

5.3.2 Python Shell Invocation

From the Python shell click the Run Script button on the tool bar and use the browser to select a script file. After clicking OK the selected script will be executed line by line in the Python Shell window.

5.3.3 Navigator Menu Invocation

Many of the Navigator Node viewers now have a Scripts drop down menu. Scripts you create can be added to viewer menus by placing them in the proper folder. ChemTree will look in the scripts sub-folder of your installation directory for scripts to add to the different viewer Script menus. If you browse to the Scripts folder you will see two more folders–one called system and one called user. Under the user folder there will be several folders named after the different Navigator Node viewers. Any script that you put in these folders will automatically appear in that viewer’s Scripts menu. For example, if you wrote a script called MySpreadsheetScript.py that works on any spreadsheet you would put it in the "/scripts/user/Spreadsheet" folder under the ChemTree installation directory. Then when ever you are using a spreadsheet viewer you can click the Scripts menu item and you will see MySpreadsheetScript as a menu option. Selecting this option will cause the script to be executed in the Python Shell.

Note that scripts can also be organized into sub-menus by creating folders inside the different viewer folders. For example, if you had a set of scripts that do analysis of a spreadsheet in different ways depending on the dataset, you could create a folder in "/scripts/user/Spreadsheet" called "Type A Scripts". Then when you clicked on the Scripts menu from the spreadsheet viewer you would see both the MySpreadsheetScript and a sub-menu called "Type A Scripts". Any scripts that you put in the "Type A Scripts" folder will be selectable from that sub-menu.

5.3.4 Script Server Invocation

ChemTree has the ability to share scripts among all users using a script server. The Script Server can be installed anywhere on your network and it will have the same set of folders for the different Navigator Node viewers as the client does. It works similar to the client in that any script put into these folders will automatically appear in every client’s Script menu assuming the client has been configured to access the Script Server. (See 5.4 for details about client configuration.) Once scripts are published to the Script Server the client will synchronize with the Server. At that point, the Server scripts can be selected and run exactly like your own custom scripts.