Hello, folks!
A trivial question - I have a working Python script that I have to
invoke from C++ code. No fancy stuff - just run the whole script with
its parameters. No callbacks, no signalling - nada, just
stupid,primitive, straightforward call.
And while there is a lot of help on embedding, I could not find out how
to run script as a whole.SOS!!!! 11 3204
volcano wrote:
Hello, folks!
A trivial question - I have a working Python script that I have to
invoke from C++ code. No fancy stuff - just run the whole script with
its parameters. No callbacks, no signalling - nada, just
stupid,primitive, straightforward call.
And while there is a lot of help on embedding, I could not find out how
to run script as a whole.SOS!!!!
In C#: http://groups.google.com/group/comp....7b6a89095ef930
hth
Gerard
Gerard Flanagan wrote:
volcano wrote:
Hello, folks!
A trivial question - I have a working Python script that I have to
invoke from C++ code. No fancy stuff - just run the whole script with
its parameters. No callbacks, no signalling - nada, just
stupid,primitive, straightforward call.
And while there is a lot of help on embedding, I could not find out how
to run script as a whole.SOS!!!!
In C#:
http://groups.google.com/group/comp....7b6a89095ef930
hth
Gerard
Thanks for fast response, alas - it did not!
My problem is - application in C++ used to use external application,
which does not work well. So I sort of reproduced the functionality in
Python script, but now I am stuck, unable to run it properly.
volcano wrote:
Gerard Flanagan wrote:
volcano wrote:
Hello, folks!
A trivial question - I have a working Python script that I have to
invoke from C++ code. No fancy stuff - just run the whole script with
its parameters. No callbacks, no signalling - nada, just
stupid,primitive, straightforward call.
>
And while there is a lot of help on embedding, I could not find out how
to run script as a whole.SOS!!!!
In C#: http://groups.google.com/group/comp....7b6a89095ef930
hth
Gerard
Thanks for fast response, alas - it did not!
My problem is - application in C++ used to use external application,
which does not work well. So I sort of reproduced the functionality in
Python script, but now I am stuck, unable to run it properly.
Maybe my understanding is wrong, but can't managed (.NET) C++ call into
any other managed assembly, in this case (I think) System.Diagnostics?
Gerard
Gerard Flanagan wrote:
volcano wrote:
Gerard Flanagan wrote:
volcano wrote:
Hello, folks!
A trivial question - I have a working Python script that I have to
invoke from C++ code. No fancy stuff - just run the whole script with
its parameters. No callbacks, no signalling - nada, just
stupid,primitive, straightforward call.
And while there is a lot of help on embedding, I could not find out how
to run script as a whole.SOS!!!!
>
In C#:
> http://groups.google.com/group/comp....7b6a89095ef930
>
hth
>
Gerard
Thanks for fast response, alas - it did not!
My problem is - application in C++ used to use external application,
which does not work well. So I sort of reproduced the functionality in
Python script, but now I am stuck, unable to run it properly.
Maybe my understanding is wrong, but can't managed (.NET) C++ call into
any other managed assembly, in this case (I think) System.Diagnostics?
Gerard
My application is written in regular C++:(
A trivial question - I have a working Python script that I have to
invoke from C++ code. No fancy stuff - just run the whole script with
its parameters. No callbacks, no signalling - nada, just
stupid,primitive, straightforward call.
And while there is a lot of help on embedding, I could not find out how
to run script as a whole.SOS!!!!
System::Diagnostics::Process::Start
A trivial question - I have a working Python script that I have to
invoke from C++ code. No fancy stuff - just run the whole script with
its parameters. No callbacks, no signalling - nada, just
stupid,primitive, straightforward call.
And while there is a lot of help on embedding, I could not find out how
to run script as a whole.SOS!!!!
System::Diagnostics::Process::Start
volcano wrote:
Hello, folks!
A trivial question - I have a working Python script that I have to
invoke from C++ code. No fancy stuff - just run the whole script with
its parameters. No callbacks, no signalling - nada, just
stupid,primitive, straightforward call.
And while there is a lot of help on embedding, I could not find out how
to run script as a whole.SOS!!!!
Thanks a lot to all of you who cared to answer! Eventually it was
"::CreateProcess", and it works!
But here is another question for gurus: sometimes my script fails, and
I cannot figure out why. OK, I can - especially since I terminate it
with "sys.exit()", but I want my app to know too.
"GetLastError" returns 0 - for the obvious reason that this is the
value Python interpreter returns with. But how can I get the script
return value?
In article <11*********************@i3g2000cwc.googlegroups.c om>,
volcano <Ma*********@gmail.comwrote:
volcano wrote:
volcano wrote:
Hello, folks!
A trivial question - I have a working Python script that I have to
invoke from C++ code. No fancy stuff - just run the whole script with
its parameters. No callbacks, no signalling - nada, just
stupid,primitive, straightforward call.
And while there is a lot of help on embedding, I could not find out how
to run script as a whole.SOS!!!!
Thanks a lot to all of you who cared to answer! Eventually it was
"::CreateProcess", and it works!
I used to find http://pinvoke.net a good resource when I was doing
Active Directory stuff. Just for interest's sake, cutting and pasting
from the CreateProcess page, the following arcana will start Python (
again from C#, but here you can see the internals at least):
using System;
using System.Runtime.InteropServices;
class Class1
{
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct STARTUPINFO
{
Int32 cb;
string lpReserved;
string lpDesktop;
string lpTitle;
Int32 dwX;
Int32 dwY;
Int32 dwXSize;
Int32 dwYSize;
Int32 dwXCountChars;
Int32 dwYCountChars;
Int32 dwFillAttribute;
Int32 dwFlags;
Int16 wShowWindow;
Int16 cbReserved2;
IntPtr lpReserved2;
IntPtr hStdInput;
IntPtr hStdOutput;
IntPtr hStdError;
}
[StructLayout(LayoutKind.Sequential)]
public struct PROCESS_INFORMATION
{
public IntPtr hProcess;
IntPtr hThread;
public int dwProcessId;
public int dwThreadId;
}
[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES
{
public int nLength;
public IntPtr lpSecurityDescriptor;
public int bInheritHandle;
}
[DllImport("kernel32.dll")]
public static extern bool CreateProcess(string lpApplicationName,
string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes,
ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandles,
uint dwCreationFlags, IntPtr lpEnvironment, string
lpCurrentDirectory,
ref STARTUPINFO lpStartupInfo,
out PROCESS_INFORMATION lpProcessInformation);
[STAThread]
static void Main(string[] args)
{
const uint NORMAL_PRIORITY_CLASS = 0x0020;
bool retValue;
string Application = @"c:\python\python24\python.exe";
string CommandLine = "";
PROCESS_INFORMATION pInfo = new PROCESS_INFORMATION();
STARTUPINFO sInfo = new STARTUPINFO();
SECURITY_ATTRIBUTES pSec = new SECURITY_ATTRIBUTES();
SECURITY_ATTRIBUTES tSec = new SECURITY_ATTRIBUTES();
pSec.nLength = Marshal.SizeOf(pSec);
tSec.nLength = Marshal.SizeOf(tSec);
retValue = CreateProcess(Application,CommandLine,
ref pSec,ref tSec,false,NORMAL_PRIORITY_CLASS,
IntPtr.Zero,null,ref sInfo,out pInfo);
}
}
volcano wrote:
volcano wrote:
Hello, folks!
A trivial question - I have a working Python script that I have to
invoke from C++ code. No fancy stuff - just run the whole script with
its parameters. No callbacks, no signalling - nada, just
stupid,primitive, straightforward call.
And while there is a lot of help on embedding, I could not find out how
to run script as a whole.SOS!!!!
Thanks a lot to all of you who cared to answer! Eventually it was
"::CreateProcess", and it works!
I used to find http://pinvoke.net a good resource when I was doing
Active Directory stuff. Just for interest's sake, cutting and pasting
from the CreateProcess page, the following arcana will start Python (
again from C#, but here you can see the internals at least):
using System;
using System.Runtime.InteropServices;
class Class1
{
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct STARTUPINFO
{
Int32 cb;
string lpReserved;
string lpDesktop;
string lpTitle;
Int32 dwX;
Int32 dwY;
Int32 dwXSize;
Int32 dwYSize;
Int32 dwXCountChars;
Int32 dwYCountChars;
Int32 dwFillAttribute;
Int32 dwFlags;
Int16 wShowWindow;
Int16 cbReserved2;
IntPtr lpReserved2;
IntPtr hStdInput;
IntPtr hStdOutput;
IntPtr hStdError;
}
[StructLayout(LayoutKind.Sequential)]
public struct PROCESS_INFORMATION
{
public IntPtr hProcess;
IntPtr hThread;
public int dwProcessId;
public int dwThreadId;
}
[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES
{
public int nLength;
public IntPtr lpSecurityDescriptor;
public int bInheritHandle;
}
[DllImport("kernel32.dll")]
public static extern bool CreateProcess(string lpApplicationName,
string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes,
ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandles,
uint dwCreationFlags, IntPtr lpEnvironment, string
lpCurrentDirectory,
ref STARTUPINFO lpStartupInfo,
out PROCESS_INFORMATION lpProcessInformation);
[STAThread]
static void Main(string[] args)
{
const uint NORMAL_PRIORITY_CLASS = 0x0020;
bool retValue;
string Application = @"c:\python\python24\python.exe";
string CommandLine = "";
PROCESS_INFORMATION pInfo = new PROCESS_INFORMATION();
STARTUPINFO sInfo = new STARTUPINFO();
SECURITY_ATTRIBUTES pSec = new SECURITY_ATTRIBUTES();
SECURITY_ATTRIBUTES tSec = new SECURITY_ATTRIBUTES();
pSec.nLength = Marshal.SizeOf(pSec);
tSec.nLength = Marshal.SizeOf(tSec);
retValue = CreateProcess(Application,CommandLine,
ref pSec,ref tSec,false,NORMAL_PRIORITY_CLASS,
IntPtr.Zero,null,ref sInfo,out pInfo);
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Aahz |
last post by:
There seems to be some kind of problem with Starship's DNS. Until it's
fixed, please use the direct IP of 217.160.219.194
--
Aahz (aahz@pythoncraft.com) <*> ...
|
by: Samuel Schulenburg |
last post by:
Who should I contact about accessing my account on Starship. I need to
obtain a new password and access process.
I think i am having a memory lapse as it has been over a year sense I
have had a...
|
by: Greg |
last post by:
The following article from microsoft describes a workaroind for a bug
in hte beta version of VISUAL PYTHON DOT NET
...
|
by: Ajay |
last post by:
hi!
Is it possible for me to have part of my application written using C#.NET
and then have it called from within a Python program.
thanks
cheers
|
by: Harlin |
last post by:
Has anyone had any success using py2exe with anything you've written
using the Python .NET implementation? (This is the one from the Zope
website -- not ActiveState). I seem to be having trouble...
|
by: Oleg Medyanik |
last post by:
Hello, All
I have a question regarding running .NET application on W2k SP4 server in
Terminal Service client,
After we installed SP4 we face the exception when closing .NET app in
Terminal...
|
by: Tobias Nilsson |
last post by:
I have almost exactly the same problem as the guy below.
Is it NOT possible running .NET code locally in Internet Explorer WITHOUT a
webserver????
/ Tobias
---------
My company has in the...
|
by: Juba |
last post by:
Hello,
I've been having trouble running my web application developed in .NET with
C# on Macs. It looks normal on PCs but Mac users are complaining that
everything looks scrambled on the screen!...
|
by: T. Bryan |
last post by:
We are now ready to start re-enabling user accounts on starship.python.net.
If you had an account on the machine, then you should have received an
e-mail about it already. If you didn't, you...
|
by: Tom Bryan |
last post by:
One of the system administrators had to reboot starship.python.net last
night, but it appears that the machine did not come back up properly.
starship.python.net is currently down while we...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |