Re: Re: Have existing python script file that I want to execute from within a cherrypy web site/page. How can this be done 100% native to cherrypy?

Sviatoslav Sydorenko <[email protected]> Sun, 29 Apr 2018 06:21:05 +0000
Newsgroups gmane.comp.python.cherrypy
Message-ID <CAFYONRB+OfK2A6OqjfWxSZYFMZe=bpyoWOnKMoE_aSLp57zKLg@mail.gmail.com>
1) don't use os module to spawn subprocesses, just have a function in those
modules, import it and call it then.
2) you probably wrote scripts in a manner/syntax, which is incompatible
with Python 3 and run CherryPy under Python 3. Or maybe just a way you run
scripts is different when you spawn subprocesses. Anyway, I'd recommend you
to not use subprocesses and do normal direct imports.
To mitigate cross python compatibility problems I strongly recommend you
writing scripts using syntax, which works in both or completely switch to
Python 3.
Look for a package distribution called "six", it may provide you some
helpers for cross compat.

--Sviatoslav.

Sent from my phone, please pardon any typos.


On Sun, Apr 29, 2018, 06:12 <[email protected]> wrote:

> Yeah, I got a variant of it working.  Not sure it is pretty, but works.
> We have a lot of existing python scripts we want to continue to use from
> console (Linux).  We just wanted to wrapper these with some simple web
> pages, to make them a bit easier to use.  So, I just imported the os
> module, can execute the script.  This is all internal stuff, nothing that
> has to be production hardened or such.  This lets the guys writing the
> python scripts for console do their thing, and lets me provide another
> avenue for execution.
>
> I plan to swing back around on this one, and do more work, but using os
> module for now works.  I did notice one odd thing, a couple of our python
> classes/functions that work great from console, break when I import them to
> a CherryPy script, and then execute as you note.  One error is that bit
> shifting with the '<<' operator gripes about how it is used.  Only get that
> error, when the given function/routine is imported to CherryPy
> environment.  From console (python 2), no error at all.
>
>
> On Saturday, April 28, 2018 at 1:04:56 PM UTC-7, [email protected] wrote:
>>
>> Have existing python script file that I want to execute from within a
>> cherrypy web site/page.  How can this be done 100% native to cherrypy?
>> Many examples reference java or CGI mods, that is not acceptable nor should
>> it be IMHO.  There has to be a 100% cherrypi method to do this, no?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "cherrypy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
> To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
> Visit this group at https://groups.google.com/group/cherrypy-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.