grail.gsys module

Version: 16.2

Table of Contents

Description

System module for the MineSight® Grail. This module contains some of the major system components used throughout all of MineSight® Grail.

Helper

GMAIN(main_function, name):

New in version 4.70.

Utility for quickly letting you define the 'standard' gmain entry point for all MineSight(r) scripts.

from grail import gsys

def run():
    
# Run my code...

gmain = gsys.GMAIN(run, __name__)
gmain.run()

This little snippet will execute your main_function if you are running from the command line OR if you are running from within MS3D. This is determined by inspecting the name argument.

The object returned must be named gmain.

The gmain object can also be queried for further properties, namely,

args : list
If the script is executed from the command line, a gmain.args will be populated with a list of command line arguments, where the first argument is the command line.
is_cl : Boolean
Set to True if the script is being executed from the command line. You can use the args property to get the list of arguments supplied to the script.
is_ip : Boolean
Set to True if the script is being executed within MSIP.
is_ms3d: Boolean
Set to True if the script is being executed within MS3D.
is_mscompass : Boolean
Set to True if the script is being executed within MSCOMPASS.
actual_path : string
This is set to the actual location that a script was executed from. For a PY/PYC file, the actual and logical locations are equal; however, for a PYZ the actual path will correspond to unpacked location, and the logical path will refer to the place where the PYZ originally resided.
logical_path : string
This is set to the location that a script was selected. For a PY/PYC file, the actual and logical locations are equal; however, for a PYZ the actual path will correspond to unpacked location, and the logical path will refer to the place where the PYZ originally resided.

Some examples are,

from grail import gsys

def run():
   
if gmain.is_cl:
      
params, options = parse_args(gmain.args)
   
else:
      
params, options = get_defaults()
   
do_something(params, options)

gmain = gsys.GMAIN(run, __name__)
gmain.run()

you can see that the gmain object will have properties that indicate the context that the script was executed in.

Functions

getdialogregistry(filename)
Returns a standard registry for a dialog. Internal usage only.
getgrailregistry()
Returns the standard WinRegistry object for the MineSight® Grail's key. Internal usage only.
grailmain(message, data)

Generic catch-all main function.

This allows us to write scripts and feed messages and data off to one place for all scripts.

An example of using this involves using gmain(),

from grail import gsys
from grail import messages

def gmain(message, data):
   
if message is messages.gRUN:
      
domyrunstuff()
   
else:
     
return gsys.grailmain(messaged, data)
Arguments:
message : integer
A messages as defined in grail.messages. The type of message sent effects the type of data that accompanies the message.
data : any
This could take any form and generally accompanies a message.