From: adam g. <ada...@ho...> - 2007-06-30 16:27:14
|
Meant to send this to the full list for archive purposes. =20 -adam =20 From: ada...@ho...To: ast...@gm...Subject: RE: [Jython-= users] Jython2.2b2 determining OS/platform and executing external programsD= ate: Sat, 30 Jun 2007 12:23:19 -0400 Heres an excerpt from my homebrew Selenium framework which answers the firs= t part of your question.# jython doesnt really have a sys.platformif java.l= ang.System.getProperty("os.name").lower().startswith("windows"): platfor= m =3D "win32"else: print "Ummm, don't have to do any other platforms rig= ht now" sys.exit(1) As for the second, look at the popen2 module. -ad= am > Date: Sat, 30 Jun 2007 23:19:07 +0800> From: ast...@gm...> To: jy= tho...@li...> Subject: [Jython-users] Jython2.2b2 deter= mining OS/platform and executing external programs> > >>> import sys, os> >= >> sys.platform> 'java1.6.0_01'> >>> os.name> 'java'> > How do I actually k= now if the OS is Windows or UNIX or whatever?> > Second question, how do I = run an external program? One that will work> for ANY platform (Windows, *ni= x, etc).. I just want to launch a> user-specified browser and make it open = a URL.> > I would prefer a pythonic solution rather than java.> > Regards,>= astigmatik> > ------------------------------------------------------------= -------------> This SF.net email is sponsored by DB2 Express> Download DB2 = Express C - the FREE version of DB2 express and take> control of your XML. = No limits. Just data. Click to get it now.> http://sourceforge.net/powerbar= /db2/> _______________________________________________> Jython-users mailin= g list> Jyt...@li...> https://lists.sourceforge.net/l= ists/listinfo/jython-users Discover the new Windows Vista Learn more!=20 _________________________________________________________________ News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx= |
From: Michael M. <mm...@gm...> - 2007-06-30 16:41:05
|
I am looking into it now but it would be great is we could get the ' subprocess.py' module working under Jython 2.2. It works under CPython 2.2and higher... so it shouldn't be that bad to get working under the current Jython. I browsed in the source and it does a lot of condition checking / setting based on OS platform (currently Win32 and UNIX) so some Jython specific code would be in order I am sure. I use subprocess.py all the time for launching external processes.. and its awesome. > ------------------------------ > > From: ada...@ho... > To: ast...@gm... > Subject: RE: [Jython-users] Jython2.2b2 determining OS/platform and > executing external programs > Date: Sat, 30 Jun 2007 12:23:19 -0400 > > Heres an excerpt from my homebrew Selenium framework which answers the > first part of your question. > > # jython doesnt really have a sys.platform > if java.lang.System.getProperty("os.name").lower().startswith("windows"): > platform = "win32" > else: > print "Ummm, don't have to do any other platforms right now" > sys.exit(1) > > As for the second, look at the popen2 module. > > -adam > > > > ------------------------------ > > > > Date: Sat, 30 Jun 2007 23:19:07 +0800 > > From: ast...@gm... > > To: jyt...@li... > > Subject: [Jython-users] Jython2.2b2 determining OS/platform and > executing external programs > > > > >>> import sys, os > > >>> sys.platform > > 'java1.6.0_01' > > >>> os.name > > 'java' > > > > How do I actually know if the OS is Windows or UNIX or whatever? > > > > Second question, how do I run an external program? One that will work > > for ANY platform (Windows, *nix, etc).. I just want to launch a > > user-specified browser and make it open a URL. > > > > I would prefer a pythonic solution rather than java. > > > > Regards, > > astigmatik > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Jython-users mailing list > > Jyt...@li... > > https://lists.sourceforge.net/lists/listinfo/jython-users > > > > ------------------------------ > > Discover the new Windows Vista Learn more!<http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE> > > ------------------------------ > Get news, entertainment and everything you care about at Live.com. Check > it out! <http://www.live.com/getstarted.aspx+> > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > > |
From: <ast...@gm...> - 2007-06-30 22:35:36
|
I ended up with a Javanese solution: browser = r'c:\program files\mozilla firefox\firefox.exe' from java.lang import Runtime Runtime.getRuntime().exec((browser, url)) Question is, would this work on non-Windows platforms? |
From: Frank W. <fwi...@gm...> - 2007-07-01 02:25:44
|
On 6/30/07, ast...@gm... <ast...@gm...> wrote: > I ended up with a Javanese solution: > > browser = r'c:\program files\mozilla firefox\firefox.exe' > from java.lang import Runtime > Runtime.getRuntime().exec((browser, url)) > > Question is, would this work on non-Windows platforms? It would work in principle, but you would need to use a platform specific path and executable name (for example, on linux it would look something like: browser = r'/usr/lib/firefox' from java.lang import Runtime Runtime.getRuntime().exec((browser, url)) and on OS X you could probably achieve a similar effect like so: browser = r'/usr/bin/open' from java.lang import Runtime Runtime.getRuntime().exec((browser, url)) although in the OS X case this would open whatever OS X would think of as the appropriate app for the particular resource pointed to with url. -Frank |
From: <ast...@gm...> - 2007-07-01 02:36:23
|
It was just an example. I'll get the value of 'browser' from users' preference. On 7/1/07, Frank Wierzbicki <fwi...@gm...> wrote: > On 6/30/07, ast...@gm... <ast...@gm...> wrote: > > I ended up with a Javanese solution: > > > > browser = r'c:\program files\mozilla firefox\firefox.exe' > > from java.lang import Runtime > > Runtime.getRuntime().exec((browser, url)) > > > > Question is, would this work on non-Windows platforms? > It would work in principle, but you would need to use a platform > specific path and executable name (for example, on linux it would look > something like: > > browser = r'/usr/lib/firefox' > from java.lang import Runtime > Runtime.getRuntime().exec((browser, url)) > > and on OS X you could probably achieve a similar effect like so: > > browser = r'/usr/bin/open' > from java.lang import Runtime > Runtime.getRuntime().exec((browser, url)) > > although in the OS X case this would open whatever OS X would think of > as the appropriate app for the particular resource pointed to with > url. > > -Frank > |
From: Oti <oh...@gm...> - 2007-07-01 21:02:22
|
Hi, the caller of Runtime.exec() needs to consume the output of the started process. So in general I'd recommend to use os.system(), which IMHO handles this for you. Of course you still have to deal with the syntax details of the platforms. Best wishes, Oti. On 7/1/07, ast...@gm... <ast...@gm...> wrote: > > It was just an example. I'll get the value of 'browser' from users' > preference. > > On 7/1/07, Frank Wierzbicki <fwi...@gm...> wrote: > > On 6/30/07, ast...@gm... <ast...@gm...> wrote: > > > I ended up with a Javanese solution: > > > > > > browser = r'c:\program files\mozilla firefox\firefox.exe' > > > from java.lang import Runtime > > > Runtime.getRuntime().exec((browser, url)) > > > > > > Question is, would this work on non-Windows platforms? > > It would work in principle, but you would need to use a platform > > specific path and executable name (for example, on linux it would look > > something like: > > > > browser = r'/usr/lib/firefox' > > from java.lang import Runtime > > Runtime.getRuntime().exec((browser, url)) > > > > and on OS X you could probably achieve a similar effect like so: > > > > browser = r'/usr/bin/open' > > from java.lang import Runtime > > Runtime.getRuntime().exec((browser, url)) > > > > although in the OS X case this would open whatever OS X would think of > > as the appropriate app for the particular resource pointed to with > > url. > > > > -Frank > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |
From: <ast...@gm...> - 2007-07-02 02:24:21
|
If I use os.system(), it 'blocks' my app until I close that external app. Also, I don't know how to pass a parameter with os.system(). I just want to be able to double-click a URL in a JEditorPane and make it open an external browser which is the preference of the user, and that browser opens the clicked URL (not necessarily the browser that is associated with opening URLs). The output of that is not important. I also don't want to read/write from that process. I just want it to open and leave it at that. And I was hoping to find a solution that'll work for all OSes. If Runtime.getRuntime().exe() is not the answer, then how do I do this? I've looked at popen, and I think it's too complicated for something so simple. On 7/2/07, Oti <oh...@gm...> wrote: > Hi, > > the caller of Runtime.exec() needs to consume the output of the started > process. > So in general I'd recommend to use os.system(), which IMHO handles this for > you. > Of course you still have to deal with the syntax details of the platforms. > > Best wishes, > Oti. > > > On 7/1/07, ast...@gm... <ast...@gm... > wrote: > > > > It was just an example. I'll get the value of 'browser' from users' > preference. > > > > On 7/1/07, Frank Wierzbicki <fwi...@gm...> wrote: > > > On 6/30/07, ast...@gm... < ast...@gm...> wrote: > > > > I ended up with a Javanese solution: > > > > > > > > browser = r'c:\program files\mozilla firefox\firefox.exe' > > > > from java.lang import Runtime > > > > Runtime.getRuntime().exec((browser, url)) > > > > > > > > Question is, would this work on non-Windows platforms? > > > It would work in principle, but you would need to use a platform > > > specific path and executable name (for example, on linux it would look > > > something like: > > > > > > browser = r'/usr/lib/firefox' > > > from java.lang import Runtime > > > Runtime.getRuntime().exec((browser, url)) > > > > > > and on OS X you could probably achieve a similar effect like so: > > > > > > browser = r'/usr/bin/open' > > > from java.lang import Runtime > > > Runtime.getRuntime().exec((browser, url)) > > > > > > although in the OS X case this would open whatever OS X would think of > > > as the appropriate app for the particular resource pointed to with > > > url. > > > > > > -Frank > > > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Jython-users mailing list > > Jyt...@li... > > https://lists.sourceforge.net/lists/listinfo/jython-users > > > > |
From: Oti <oh...@gm...> - 2007-07-02 04:45:39
|
Sorry I was not aware you don't want to block. Reading the javadoc of Process http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Process.html makes me believe it is not defined. best wishes, Oti. In any case, On 7/2/07, ast...@gm... <ast...@gm...> wrote: > > If I use os.system(), it 'blocks' my app until I close that external > app. Also, I don't know how to pass a parameter with os.system(). > > I just want to be able to double-click a URL in a JEditorPane and make > it open an external browser which is the preference of the user, and > that browser opens the clicked URL (not necessarily the browser that > is associated with opening URLs). The output of that is not important. > I also don't want to read/write from that process. I just want it to > open and leave it at that. And I was hoping to find a solution that'll > work for all OSes. > > If Runtime.getRuntime().exe() is not the answer, then how do I do > this? I've looked at popen, and I think it's too complicated for > something so simple. > > > On 7/2/07, Oti <oh...@gm...> wrote: > > Hi, > > > > the caller of Runtime.exec() needs to consume the output of the started > > process. > > So in general I'd recommend to use os.system(), which IMHO handles this > for > > you. > > Of course you still have to deal with the syntax details of the > platforms. > > > > Best wishes, > > Oti. > > > > > > On 7/1/07, ast...@gm... <ast...@gm... > wrote: > > > > > > It was just an example. I'll get the value of 'browser' from users' > > preference. > > > > > > On 7/1/07, Frank Wierzbicki <fwi...@gm...> wrote: > > > > On 6/30/07, ast...@gm... < ast...@gm...> wrote: > > > > > I ended up with a Javanese solution: > > > > > > > > > > browser = r'c:\program files\mozilla firefox\firefox.exe' > > > > > from java.lang import Runtime > > > > > Runtime.getRuntime().exec((browser, url)) > > > > > > > > > > Question is, would this work on non-Windows platforms? > > > > It would work in principle, but you would need to use a platform > > > > specific path and executable name (for example, on linux it would > look > > > > something like: > > > > > > > > browser = r'/usr/lib/firefox' > > > > from java.lang import Runtime > > > > Runtime.getRuntime().exec((browser, url)) > > > > > > > > and on OS X you could probably achieve a similar effect like so: > > > > > > > > browser = r'/usr/bin/open' > > > > from java.lang import Runtime > > > > Runtime.getRuntime().exec((browser, url)) > > > > > > > > although in the OS X case this would open whatever OS X would think > of > > > > as the appropriate app for the particular resource pointed to with > > > > url. > > > > > > > > -Frank > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by DB2 Express > > > Download DB2 Express C - the FREE version of DB2 express and take > > > control of your XML. No limits. Just data. Click to get it now. > > > http://sourceforge.net/powerbar/db2/ > > > _______________________________________________ > > > Jython-users mailing list > > > Jyt...@li... > > > https://lists.sourceforge.net/lists/listinfo/jython-users > > > > > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |
From: Michael C. <chi...@mi...> - 2007-07-02 14:46:32
|
Fyi, Java 6 comes with this sort of capability built-in. See http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html , in particular the browse() method. I haven't tried it myself, so I don't know whether this blocks or not. Andy ast...@gm... wrote: > If I use os.system(), it 'blocks' my app until I close that external > app. Also, I don't know how to pass a parameter with os.system(). > > I just want to be able to double-click a URL in a JEditorPane and make > it open an external browser which is the preference of the user, and > that browser opens the clicked URL (not necessarily the browser that > is associated with opening URLs). The output of that is not important. > I also don't want to read/write from that process. I just want it to > open and leave it at that. And I was hoping to find a solution that'll > work for all OSes. > > If Runtime.getRuntime().exe() is not the answer, then how do I do > this? I've looked at popen, and I think it's too complicated for > something so simple. > > > On 7/2/07, Oti <oh...@gm...> wrote: > >> Hi, >> >> the caller of Runtime.exec() needs to consume the output of the started >> process. >> So in general I'd recommend to use os.system(), which IMHO handles this for >> you. >> Of course you still have to deal with the syntax details of the platforms. >> >> Best wishes, >> Oti. >> >> >> On 7/1/07, ast...@gm... <ast...@gm... > wrote: >> >>> It was just an example. I'll get the value of 'browser' from users' >>> >> preference. >> >>> On 7/1/07, Frank Wierzbicki <fwi...@gm...> wrote: >>> >>>> On 6/30/07, ast...@gm... < ast...@gm...> wrote: >>>> >>>>> I ended up with a Javanese solution: >>>>> >>>>> browser = r'c:\program files\mozilla firefox\firefox.exe' >>>>> from java.lang import Runtime >>>>> Runtime.getRuntime().exec((browser, url)) >>>>> >>>>> Question is, would this work on non-Windows platforms? >>>>> >>>> It would work in principle, but you would need to use a platform >>>> specific path and executable name (for example, on linux it would look >>>> something like: >>>> >>>> browser = r'/usr/lib/firefox' >>>> from java.lang import Runtime >>>> Runtime.getRuntime().exec((browser, url)) >>>> >>>> and on OS X you could probably achieve a similar effect like so: >>>> >>>> browser = r'/usr/bin/open' >>>> from java.lang import Runtime >>>> Runtime.getRuntime().exec((browser, url)) >>>> >>>> although in the OS X case this would open whatever OS X would think of >>>> as the appropriate app for the particular resource pointed to with >>>> url. >>>> >>>> -Frank >>>> >>>> >>> >> ------------------------------------------------------------------------- >> >>> This SF.net email is sponsored by DB2 Express >>> Download DB2 Express C - the FREE version of DB2 express and take >>> control of your XML. No limits. Just data. Click to get it now. >>> http://sourceforge.net/powerbar/db2/ >>> _______________________________________________ >>> Jython-users mailing list >>> Jyt...@li... >>> https://lists.sourceforge.net/lists/listinfo/jython-users >>> >>> >> > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > > |
From: Michael C. <chi...@mi...> - 2007-07-02 14:52:11
|
"But not necessarily the one associated with URLs"... ok I replied a little too fast on that :) Nevermind, Desktop.browse() would just use the platform default. Michael Chisholm wrote: > Fyi, Java 6 comes with this sort of capability built-in. See > http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html , in > particular the browse() method. I haven't tried it myself, so I don't > know whether this blocks or not. > > Andy > > ast...@gm... wrote: > >> If I use os.system(), it 'blocks' my app until I close that external >> app. Also, I don't know how to pass a parameter with os.system(). >> >> I just want to be able to double-click a URL in a JEditorPane and make >> it open an external browser which is the preference of the user, and >> that browser opens the clicked URL (not necessarily the browser that >> is associated with opening URLs). The output of that is not important. >> I also don't want to read/write from that process. I just want it to >> open and leave it at that. And I was hoping to find a solution that'll >> work for all OSes. >> >> If Runtime.getRuntime().exe() is not the answer, then how do I do >> this? I've looked at popen, and I think it's too complicated for >> something so simple. >> >> >> On 7/2/07, Oti <oh...@gm...> wrote: >> >> >>> Hi, >>> >>> the caller of Runtime.exec() needs to consume the output of the started >>> process. >>> So in general I'd recommend to use os.system(), which IMHO handles this for >>> you. >>> Of course you still have to deal with the syntax details of the platforms. >>> >>> Best wishes, >>> Oti. >>> >>> >>> On 7/1/07, ast...@gm... <ast...@gm... > wrote: >>> >>> >>>> It was just an example. I'll get the value of 'browser' from users' >>>> >>>> >>> preference. >>> >>> >>>> On 7/1/07, Frank Wierzbicki <fwi...@gm...> wrote: >>>> >>>> >>>>> On 6/30/07, ast...@gm... < ast...@gm...> wrote: >>>>> >>>>> >>>>>> I ended up with a Javanese solution: >>>>>> >>>>>> browser = r'c:\program files\mozilla firefox\firefox.exe' >>>>>> from java.lang import Runtime >>>>>> Runtime.getRuntime().exec((browser, url)) >>>>>> >>>>>> Question is, would this work on non-Windows platforms? >>>>>> >>>>>> >>>>> It would work in principle, but you would need to use a platform >>>>> specific path and executable name (for example, on linux it would look >>>>> something like: >>>>> >>>>> browser = r'/usr/lib/firefox' >>>>> from java.lang import Runtime >>>>> Runtime.getRuntime().exec((browser, url)) >>>>> >>>>> and on OS X you could probably achieve a similar effect like so: >>>>> >>>>> browser = r'/usr/bin/open' >>>>> from java.lang import Runtime >>>>> Runtime.getRuntime().exec((browser, url)) >>>>> >>>>> although in the OS X case this would open whatever OS X would think of >>>>> as the appropriate app for the particular resource pointed to with >>>>> url. >>>>> >>>>> -Frank >>>>> >>>>> >>>>> >>>> >>>> >>> ------------------------------------------------------------------------- >>> >>> >>>> This SF.net email is sponsored by DB2 Express >>>> Download DB2 Express C - the FREE version of DB2 express and take >>>> control of your XML. No limits. Just data. Click to get it now. >>>> http://sourceforge.net/powerbar/db2/ >>>> _______________________________________________ >>>> Jython-users mailing list >>>> Jyt...@li... >>>> https://lists.sourceforge.net/lists/listinfo/jython-users >>>> >>>> >>>> >>> >>> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> _______________________________________________ >> Jython-users mailing list >> Jyt...@li... >> https://lists.sourceforge.net/lists/listinfo/jython-users >> >> >> > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > > |
From: Updike, C. <Cla...@jh...> - 2007-07-02 18:22:34
|
I've not tried either of these, but you might also want to check them out: http://www.centerkey.com/java/browser/ If you're using Java6: http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html -Clark=20 > -----Original Message----- > From: jyt...@li...=20 > [mailto:jyt...@li...] On Behalf=20 > Of ast...@gm... > Sent: Saturday, June 30, 2007 10:36 PM > To: jyt...@li... > Subject: Re: [Jython-users] FW: Jython2.2b2 determining=20 > OS/platform andexecuting external programs >=20 > It was just an example. I'll get the value of 'browser' from=20 > users' preference. >=20 > On 7/1/07, Frank Wierzbicki <fwi...@gm...> wrote: > > On 6/30/07, ast...@gm... <ast...@gm...> wrote: > > > I ended up with a Javanese solution: > > > > > > browser =3D r'c:\program files\mozilla firefox\firefox.exe' > > > from java.lang import Runtime > > > Runtime.getRuntime().exec((browser, url)) > > > > > > Question is, would this work on non-Windows platforms? > > It would work in principle, but you would need to use a platform=20 > > specific path and executable name (for example, on linux it=20 > would look=20 > > something like: > > > > browser =3D r'/usr/lib/firefox' > > from java.lang import Runtime > > Runtime.getRuntime().exec((browser, url)) > > > > and on OS X you could probably achieve a similar effect like so: > > > > browser =3D r'/usr/bin/open' > > from java.lang import Runtime > > Runtime.getRuntime().exec((browser, url)) > > > > although in the OS X case this would open whatever OS X=20 > would think of=20 > > as the appropriate app for the particular resource pointed to with=20 > > url. > > > > -Frank > > >=20 > -------------------------------------------------------------- > ----------- > This SF.net email is sponsored by DB2 Express Download DB2=20 > Express C - the FREE version of DB2 express and take control=20 > of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users >=20 |