The perceived problem of calling PS3.py and three arguments was easily circumvented by installing the arguments in the script and dumping the original argparse routines:
# Program start
def main():
# External Variables
# These four parameters are the original .py arguments
account = 'XXXXX@XXXX.com'
password = 'xxxxxxxxxxx'
device = '$101$0-0-0-db93e8690'
startdate = '2018-01-25'
deviceList = []
deviceList.append(device)
day = datetime.datetime.now().strftime("%d")
ISOstartdate = ISOdateformatter(startdate)
year = datetime.datetime.now().strftime("%Y")
month = int(datetime.datetime.now().strftime("%m")) - 1
ISOstartdate = "{}-{}-{}T00:00:00".format(year, month, day)
tomorrow = str(int(day) + 1)
ISOenddate = "{}{}T00:00:00".format(datetime.datetime.now().strftime("%Y-%m-"), tomorrow)
# Pull metadata
findmetadata(deviceList, ISOstartdate, ISOenddate, account, password)
# if run by command line, run main()
if __name__ == '__main__':
main()
...
...
This allowed the script to run using TMemo components as in the simple Github Memo example format:
type
{ TP4L_TEST }
TP4L_TEST = class(TForm)
PythonEngine1: TPythonEngine;
PythonGUIInputOutput1: TPythonGUIInputOutput;
RS_Button: TButton;
LS_Button: TButton;
Memo1: TMemo;
Memo2: TMemo;
procedure LS_ButtonClick(Sender: TObject);
procedure RS_ButtonClick(Sender: TObject);
private
public
end;
var
P4L_TEST: TP4L_TEST;
implementation
{$R *.lfm}
{ TP4L_TEST }
procedure TP4L_TEST.LS_ButtonClick(Sender: TObject); #LOAD SCRIPT
var DatFileName:string;
begin
DatFileName:= 'c:\Code\PS3.py';
Memo1.Lines.LoadFromFile(DatFileName);
end;
procedure TP4L_TEST.RS_ButtonClick(Sender: TObject); #EXECUTE SCRIPT
begin
PythonEngine1.ExecStrings(memo1.lines);
end;
The TPythonGUIInputOutput; component enable the scrip print() outputs to be displayed The arguments are only used during system
commissioning and it is simple to set them directly iin Mem and to save thisback to the PS3.py . This satisfies my requirements but
I would certainly be interested in seeing a better way ! It proves to me that P4L runs fine in Python 3.7 and in my own Win8.1
environment. The returned Memo2 data is read but it may require conversion from u' before parsing in the windows environment.
Docwat