Functions for reading and modifying configuration of CAM32.
This module provides several convenience functions for reading various settings from the CAM.INI file on the local machine. Also, you may (at least try to) read any setting you like from that file with the cam32.config.get_ini_value() function.
Warning
A few of the functions involve (at least temporarily) changing some of CAM’s configuration. Please see the functions’ documentation for more info, and please be careful!
Note
Pretty much this entire module depends on being aware of the local CAM32 installation path. Since CAM32 itself doesn’t record this path anywhere (that I’ve found), a small INI-type file must exist for this purpose. This file must exist at <COMMON_APPDATA>\pycam32\pycam32.ini; a real-world example of that location on my WinXP machine is:
C:\Documents and Settings\All Users\Application Data\pycam32\pycam32.ini
Also, since CAM32.EXE is only installed on server machines and not client machines, the pycam32.ini file should include a path to this executable as well. Here is an entire pycam32.ini file as an example:
[CAM32]
store_number = 1
install_path = C:\CAM32
executable_path = C:\CAM32\CAM32.EXE
Returns the CAM32 store number, as defined by pycam32.ini.
Returns the local CAM32 install path, as defined by pycam32.ini.
Returns the path to the CAM32 executable, as defined by pycam32.ini.
Returns the path to the CAM.INI file.
Note
This assumes the CAM.INI file exists directly within the local CAM32 installation path, as returned by cam32.config.get_install_path().
Returns an arbitrary configuration value from CAM.INI.
Since CAM.INI doesn’t follow traditional INI-style formatting, this function allows generic parsing of their file. The name you pass should not include brackets, for example:
CAM.INI contents:
[PUBLIC] C:\CAM32\PUBLIC\
Your code:
public_path = cam32.config.get_ini_value('PUBLIC')
The (string) value is returned, or None if not found.
Convenience function which returns the PUBLIC path as defined in CAM.INI.
Convenience function which returns the PRINT path as defined in CAM.INI.
Returns the most recent file with a name starting with basename to have appeared in CAM32’s PRINT folder.
For example, if you’ve printed (to file) a receiving worksheet (e.g. as part of receiving a purchase order in CAM32), and that report’s FILE property is defined as 'PRFILE' (as per the default), then you could find the path to your new report file by executing this code:
newest_worksheet_path = cam32.config.get_last_printed('PRFILE')
Convenience function which returns CAM32’s PUBLIC path with 'IMPORT' (and optionally subdir) appended to it.
For example, the code:
po_dir = cam32.config.get_import_path('PURCHASE_ORDERS')
would output (on my machine):
C:\CAM32\PUBLIC\IMPORT\PURCHASE_ORDERS
Returns the next available path which could be used for generating a price change file to be imported by CAM32.
Note
The price_type parameter (if provided) must be either 'NORMAL' or 'PROMOTIONAL', as that is all CAM32’s importer will recognize.
Also note that this assumes the import folder exists as would be returned by this code segment:
path = cam32.config.get_import_path('PRICE_CHANGES')
It examines any files which already exist in that folder so that it will not return a path which would cause you to overwrite a file. Assuming no other files exist in that folder, the code:
print cam32.config.get_avail_price_change_path()
would output (on my machine):
C:\CAM32\PUBLIC\IMPORT\PRICE_CHANGES\IMPORT_NORMAL_PC_1.TXT
Returns the next available path which could be used for generating a scancode data file to be imported by CAM32.