SVN Python API with TortoiseSVN - python

To use the SVN API with a Python script is it enough to have TortoiseSVN installed or do I need another SVN client?
I am using the cmd line features of tortoiseSVN but I'm looking for more advanced possibilities to work with SVN and wonder if I need to install another SVN client or so..
Thanks, Martin

Unless you're going to shell out to run a command-line program from within Python, you should be using PySvn or the "Subversion for Windows" distribution which includes Python libraries.
If you still want to run a command-line program from your Python script, use either the svn.exe that comes with the TortoiseSVN installation, or the one from the above-referenced Subversion for Windows. The TortoiseSVN command-line program (TortoiseProc.exe) is not intended to be used from within other scripts/programs like you describe.

Related

Run Python script as a Windows service on a non-Python PC

I am looking to run my new Python script as a service. The problem is the users most definitely would not have Python installed. After doing research I found the two main options: nssm and the win32serviceutil code, but as far as I understand both require a Python installation on the PC, since you have to specify the path to your python.exe.
Is there any other way to make a Python script to run as soon as Windows is started and run in the background, which doesn't require an existing Python installation?

How to configure the Jenkins ShiningPanda plugin Python Installations

The Jenkins ShiningPanda plugin provides a Managers Jenkins - Configure System setting for Python installations... which includes the ability to Install automatically. This should allow me to automatically setup Python on my slaves.
But I'm having trouble figuring out how to use it. When I use the Add Installer drop down it gives me the ability to
Extract .zip/.tar.gz
Run Batch Command
Run Shell Command
But I can't figure out how people us these options to install Python. Especially as I need to install Python on Windows, Mac, & Linux.
Other Plugins like Ant provide an Ant installations... which installs Ant automatically. Is this possible with Python?
As far as my experiments for jenkins and python goes, shining panda plug-in doesn't install python in slave machines in fact it uses the existing python library set in the jenkins configuration to run python commands.
In order to install python on slaves, I would recommend to use python virtual environment which comes along with shining panda and allows to run the python commands and then close the virtual environment.
(This is a Windows-only answer. Perhaps someone can complement this with a Linux/Unix answer, which is probably even simpler.)
Here is how we're currently doing automatic Python installations on Jenkins, with the ShiningPanda Jenkins plugin, for Python 2.7 on Windows, installing to c:\Python27:
Download the Python Windows MSI installer from https://www.python.org/downloads/windows/, and put it on some central share.
If you're running a server-version of Windows, then make sure to set DisableMsi to 0, i.e., find or create registry key HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Installer and create a value called DisableMsi and set it to zero.
On Jenkins => Manage Jenkins => Global Tool Configuration, add a 'Python installation', choose 'Install automatically' and set the label to cover all agent systems to which this applies. Then choose 'Run Batch Command', and as batch command use something like this:
if not exist c:\Python27\python.exe (
start /wait msiexec /qn /i \\some-central-system\some-share\python-2.7.14.amd64.msi /l*v python27-install-log.txt
)
as shown in the following screenshot:
(Notes on how this works: msiexec is the tool to run an MSI installer where '/i' means "install", and in the case of Python it does not require elevated permissions. /l*v does verbose logging. /qn is to make sure no UI is shown, and cmd.exe's start /wait makes sure that msiexec /i waits until the installation completes.)
That's it!
All of the above might very well work with other versions of Python as well.

RPM Post Install Execute with Python

I'm working on a deployment process for work and have run into a bit of a snag. Its more of a quality of life thing than anything else. I've been following Hynek Schlawack's excellent guide and have gotten pretty far. The long and short of what I'm trying to do is install a python application along with a deployment of the python version I'm currently using. I'm using fpm to build an RPM that will then be sent and installed to site.
As part of my deployment, I'd like to run some post-install scripts. Which I can specify in fpm using the "--post-install {SCRIPT_NAME}" This works all well and good when the script is an actual linux script. However, I'd really like to run a python script as my post-install. I can specify an executable python script, but it fails because I believe it is trying to execute the script as: bash my_python_script.py
Does anyone know if there is a way to execute a python script post-install of an RPM?
Thanks in advance!
In the spec file you can specify what interpreter the %post script is for by using the -p parameter, e.g. %post -p /usr/bin/perl .

Using Third-Party Modules with Python in an Automator Service

I have installed Py-Appscript on my machine and it can be used with the Python installation at /Library/Frameworks/Python.framework/Versions/Current/bin/python.
I am trying to use this installation of Py-Appscript with an Automator service. To do this, I use the Run Shell Script action and then set the Shell to usr/bin/python (which is my only choice for Python, unfortunately).
The usr/bin/python does not appear to have access to my third-party modules and crashes on the line:
from appscript import *
Is there a way for me to give usr/bin/python access to my third-party modules?
OR
Is there a way to tell Automator to use /Library/Frameworks/Python.framework/Versions/Current/bin/python instead?
I need Automator to run the Python directly from the Run Shell Script action. Any action that calls Python scripts that are external to Automator (via bin/bash, for example) does not perform quickly enough to be useful.
Okay, I was able to get it working using a hack found at How do I execute a PHP shell script as an Automator action on Mac OS X.
Inside of the Run Shell Script action, I used the /bin/sh/ shell with <<EOF ... EOF to the proper Python installation.
So for example, entering
/Library/Frameworks/Python.framework/Versions/Current/bin/python <<EOF
from appscript import *
Numbers = app('Numbers')
EOF
Into the code section of the Run Shell Script action will work. So one can call the proper installation (/Library/Frameworks/Python.framework/Versions/Current/bin/python above) and put their program between the <<EOF ... EOF delimeters.
Alfred
This trick works with Alfred also. If you want to use appscript with Alfred, just make sure that you pass {query} to the python version above, like this:
/Library/Frameworks/Python.framework/Versions/Current/bin/python script.py {query}
When you install modules, you typically install them per Python instance. So in this case you have installed them for the Python in /Library/Frameworks/Python.framework/Versions/Current/bin/python, and it will then be available only for that Python. /usr/bin/python is then apparently another Python installation (I'm not an OS X expert).
To make it available for the /usr/bin/python installation, install it for /usr/bin/python.

How to deploy Python to Windows users?

I'm soon to launch a beta app and this have the option to create custom integration scripts on Python.
The app will target Mac OS X and Windows, and my problem is with Windows where Python normally is not present.
My actual aproach is silently run the Python 2.6 install. However I face the problem that is not activated by default and the path is not set when use the command line options. And I fear that if Python is installed before and I upgrade to a new version this could break something else...
So, I wonder how this can be done cleanly. Is it OK if I copy the whole Python 2.6 directory, and put it in a sub-directory of my app and install everything there? Or with virtualenv is posible run diferents versions of Python (if Python is already installed in the machine?).
I also play before embedding Python with a DLL, and found it easy but I lost the ability to debug, so I switch to command-line plug-ins.
I execute the plug-ins from command line and read the STDOUT and STDERR output. The app is made with Delphi/Lazarus. I install others modules like JSON and RPC clients, Win32com, ORM, etc. I create the installer with bitrock.
UPDATE: The end-users are small business owners, and the Python scripts are made by developers. I want to avoid any additional step in the deployment, so I want a fully integrated setup.
Copy a Portable Python folder out of your installer, into the same folder as your Delphi/Lazarus app. Set all paths appropriately for that.
You might try using py2exe. It creates a .exe file with Python already included!
Integrate the python interpreter into your Delphi app with P4D. These components actually work, and in both directions too (Delphi classes exposed to Python as binary extensions, and Python interpreter inside Delphi). I also saw a patch for Lazarus compatibility on the Google Code "issues" page, but it seems there might be some unresolved issues there.
I think there's no problem combining .EXE packaging with a tool like PyInstaller or py2exe and Python-written plugins. The created .EXE can easily detect where it's installed and the code inside can then simply import files from some pre-determined plugin directory. Don't forget that once you package a Python script into an executable, it also packages the Python interpreter inside, so there you have it - a full Python environment customized with your own code.

Categories

Resources