Python Code
Moderators: JRL, Dorian (MJT support)
Python Code
Would anyone be very kind enough to share your complete MS+Python code with us?
Thank you.
Thank you.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Python Code
What are you looking for?
There's an example here:
https://www.mjtnet.com/blog/2014/11/07/ ... -recorder/
There's an example here:
https://www.mjtnet.com/blog/2014/11/07/ ... -recorder/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Python Code
Houston, I have a problem!
MS crashes at Line 37. Please rescue me.
MS crashes at Line 37. Please rescue me.
Code: Select all
/*
First ensure Python27.dll and imports are in your Macro Scheduler program folder.
Download and unzip this file:
https://www.mjtnet.com/software/python27.zip
*/
Let>url=http://ip.jsontest.com/
/*
python_code:
import urllib2
import json
# grab data from http://ip.jsontest.com/ - see www.jsontest.com
response = urllib2.urlopen('%url%')
# load the json
dict = json.loads(response.read())
# get the ip member
myip = dict["ip"]
# make a nice string representation of the dict
sdict = json.dumps(dict)
# Anything we print to IO is returned in the PYExec output var
print "All Done"
*/
//Load the Python code to a variable
LabelToVar>python_code,pcode
//Run the code and request the values of the sdict and myip variables ...
PYExec>pcode,output,sdict,myip
//Display the IP address
MessageModal>Your pubic IP is: %myip%
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Python Code
You don't say what the error is. But as well as the DLL you need the Imports. This uses urllib2 so you'll need that lib.
"First ensure Python27.dll and imports are in your Macro Scheduler program folder".
"First ensure Python27.dll and imports are in your Macro Scheduler program folder".
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Python Code
Where can I download the urllib2 please?Marcus Tettmar wrote:You don't say what the error is. But as well as the DLL you need the Imports. This uses urllib2 so you'll need that lib.
Re: Python Code
The following two files are the best I can find:
Please help. Thanks.
Code: Select all
urllib2.py
urllib2.pyc
Re: Python Code
When executing Line 37, msched.exe suddenly vanishes from Windows without leaving any traces.Marcus Tettmar wrote:You don't say what the error is.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Python Code
I think you're trying to make this more complicated - just extract the ENTIRE zip to the Macro Scheduler program folder!
1. Download this file:
https://www.mjtnet.com/software/python27.zip
2. Extract EVERYTHING from that zip into the Macro Scheduler 14 *program folder* (usually c:\program files (x86)\Macro Scheduler 14
3. You should see python27.dll as well as Lib, DLLs, and libs sub folders and these should contains a bunch of files and sub folders.
Now your script should run
1. Download this file:
https://www.mjtnet.com/software/python27.zip
2. Extract EVERYTHING from that zip into the Macro Scheduler 14 *program folder* (usually c:\program files (x86)\Macro Scheduler 14
3. You should see python27.dll as well as Lib, DLLs, and libs sub folders and these should contains a bunch of files and sub folders.
Now your script should run
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Python Code
Thank you for help. The code does work finally.Marcus Tettmar wrote:1. Download this file:
https://www.mjtnet.com/software/python27.zip
2. Extract EVERYTHING from that zip into the Macro Scheduler 14 *program folder* (usually c:\program files (x86)\Macro Scheduler 14
3. You should see python27.dll as well as Lib, DLLs, and libs sub folders and these should contains a bunch of files and sub folders.
Now your script should run
The Bible never mentions that all folders & files in python27.zip must be copied to the Macro Scheduler folder.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Python Code
It does. From the PyExec topic in the help file (or online here: https://www.mjtnet.com/manual/index.html?pyexec.htm):armsys wrote:The Bible never mentions that all folders & files in python27.zip must be copied to the Macro Scheduler folder.
Added emphasis mine.Requires the Python 2.7 DLL to be installed and in the path.
We recommend installing the python27.dll in the same folder as Macro Scheduler or of your compiled macro. Any libraries and runtimes can also be included in lib,libs,dll etc folders at the same level, consistent with the usual Python setup.
We've provided a zip file containing the Python 2.7 runtime environment which you can download from here. Export the contents to the Macro Scheduler program folder, or the folder of a compiled macro (.exe).[/size]
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Python Code
At least, the above description seems to me that only python27.dll would suffice.Marcus Tettmar wrote:Added emphasis mine.Requires the Python 2.7 DLL to be installed and in the path.
We recommend installing the python27.dll in the same folder as Macro Scheduler or of your compiled macro. Any libraries and runtimes can also be included in lib,libs,dll etc folders at the same level, consistent with the usual Python setup.
We've provided a zip file containing the Python 2.7 runtime environment which you can download from here. Export the contents to the Macro Scheduler program folder, or the folder of a compiled macro (.exe).[/size]
Sorry, my misunderstanding.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Python Code
"We've provided a zip file ....... Export the contents "
I'm sorry if that is somehow not clear.
I'm sorry if that is somehow not clear.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Python Code
In order for Python to run under MS, it requires: 3 folders & 1 file installed in C:\Program Files (x86)\Macro Scheduler 14:
DLLs (folder)
Lib (folder)
libs (folder)
python27.dll (file)
DLLs (folder)
Lib (folder)
libs (folder)
python27.dll (file)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Python Code
And a whole heap of other files inside those folders.
So just extract the entire contents of the provided zip file to your Macro Scheduler program folder, as per our instructions.
Just unzip the folder there. That's it!!
So just extract the entire contents of the provided zip file to your Macro Scheduler program folder, as per our instructions.
Just unzip the folder there. That's it!!
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?