screenshot - Executing command line script from Django & Python -


I am creating a Jejoo Management Command which is used by the website of Paul Hammond's WebKit 2 PGP script () Is making and storing them in my DB.

For this command I am using the 'call' command with 'subprocess'. How can I execute this order in a specific order (in this case under temp / django project)? My current code looks like this, but it does not get a script executing which is stored in my VirtualVen site-package folder:

  import os from django.core.management.base import NoArgsCommand import from Django.conf import subprances imported calls # models from reviews. Model Import Shop Class Command (Noegg's Command): Deaf Handle_Onorus (Own, ** Option): #Shops Outlets = Shop.Objects.L () Path = OS For shops in shopping (settings. STOROTOT, '../ANG / LIB / Python 2 / sais-package'): print shop command = "cd temporary; python% s / webkit 2png.py -F% s" % (Path, shop.url) call ([Command]) # Read the screenshot file and insert it in the model's IMFFIELD  

You need to use the cwd parameter as call . Apart from this, I advise normalizing the path before using it.

  path = os.path.normpath (os.path.join (settings.SITE_ROOT, '../env/lib/python2-6/site-package')) to shop in stores : Insert Print Shop Call (["Python", path + "/webkit2png.py", "-F", shop.url], cwd = "temp") # Read screenshot file and model in IMFFIELD  

calls takes the same logic, you can find some other things that help too. Additionally, it is best to split your command line token in the list sent to call and enter your default incorrect shell parameter>. In this way, you do not have to worry about avoiding, quote, or anything to mess up your parameters.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -