Is there a way to get the selected project of the MKS projects view gui started as a subprocess from the command line?
si.exe projects ... -g
When starting a custom tool from the MKS main gui accessing the selected project is possible by defining an environment file for that tool and parsing it for the variable name like SI_PROJECT1=... .
But it is only the selected file at tool start or more precisely it is only the environment from tool start. Changes in the gui don't have an effect on the environment file.
The gui itself unfortunately has no return value giving the selected project.
I'm trying to use the MKS si projects gui called as a subprocess from python or C# to select a specific project and use the selection for further processing.
Is there any way to do that (on Win7)?
Thanks in advance!
To use the GUI for selecting a specific project you can use the following command projectinfo from cli
si.exe projectinfo --settingsUI=gui
then parse the output of command and use the Project Name or Configuration Path, depending of your server configuration
Also, you can use the command in combination with --xmlapi and the output will be as xml ( I know that this option is not recommended in release application, is only for developing phase)
Sample output
Project Name: t:/projects/demo/project.pj
Repository Location: t:/projects/demo/project.pj
Server: mks-host:7001
Configuration Path: #t:/projects/demo
Last Checkpoint: 1.1
Last Checkpointed: Apr 21, 2011 4:10:50 PM
Members: 2
Subprojects: 6
Description:
Attributes: none
Development Paths: none
Associated Issues: none
Depending of your server version and configuration
Related
i've installed pycharm community edition 2016.
I tried to configure it to debug Odoo as illustrated in the capture
When i open a python file set a breakpoint and click debug icon i got an exception:
Also openerp, fields, api are underlined in red.
Any suggestions please. I use windows 8.1 as OS
Update:
According to Mariusz Answer , i'm now able to clic on debug bouton without any error.
Now i have put a brekpoint on a code to follow the execution, but the breakpoint is never reached ( the code is inside a buton method) while the method is executed. I can see the result in odoo page.
First question - you are not supposed to run it from exe file, but from openerp-server, which is located in odoo installation folder via python interpreter. What is more, your configuration is wrong, because Odoo does not work with Python 3.4.1
My configuration looks like this:
Second question - you need to add your sources folder in Project Structure configuration so it is recognized by PyCharm as a folder from which to import.
To be able to reach breakpoint you have to disable gevent. At the moment of writing you can do it by commenting this piece of code in openerp/__init__.py
import sys
evented = False
#if sys.modules.get("gevent") is not None:
# evented = True
I've developed a few Qt projects in C++ using Qt Creator in the past, but now I want to experiment with the Python implementation of Qt. I discovered that Qt Creator 2.8 and higher support Python, but I haven't been able to figure out how to create a Qt application in Python with it so far. Online documentation about it appears to be scarce.
How do I set up such a project in Qt Creator? Ideally I'm looking for a simple "Hello World" project that I can open in Qt Creator and use that as a starting point to build something.
Currently, Qt Creator allows you to create Python files (not projects) and run them. It also has syntax highlighting, but it lacks more complex features such as autocomplete.
Running scripts requires some configuration (I used this tutorial). Open Qt Creator and go to Tools->Options->Environment->External Tools. Click Add->Add category and create a new category (for example, Python). Then, select the created category and click Add->Add Tool to create a new tool - RunPy for example. Select the created tool and fill the fields on the right:
Description - any value
Executable - path to python.exe
Arguments - %{CurrentDocument:FilePath}
Working directory - %{CurrentDocument:Path}
Environment - QT_LOGGING_TO_CONSOLE=1
You get something like this:
Now, go to File->New File or Project->Python and select Python source file. To run the created script: Tools->External->Python->RunPy.
You can also add pyuic to it the same way:
Click again on the Add->Add Tool button to create a new tool - PyUic now. Select it again and fill the fields on the right:
Description - any value
Executable - path to pyuic5
Arguments - -o UI%{CurrentDocument:FileBaseName}.py -x %{CurrentDocument:FilePath}
Working directory - %{CurrentDocument:Path}
Environment - QT_LOGGING_TO_CONSOLE=1
Then you should have PyUic connected as well.
Thanks for this, it helped enormously.
I set up a build and run section of a new kit for python, using your instructions, which seems to work quite well.
Here are the build settings:
Here are the run settings:
note that I have /usr/bin/python as a link to /usr/bin/python3.6
Here are the project file settings:
The only thing that is necessary is to go into tools -> options -> build and run and unselect 'always build project before deploying it' and 'always deploy project before running it'.
Once you have designed a form, you can then click build to create the UI.py file and run the currently selected python source file by clicking run.
For PyQt noobs like myself, I found the following resource to be particularly helpful at getting started... (although I am on linux rather than windows)...
http://projects.skylogic.ca/blog/how-to-install-pyqt5-and-build-your-first-gui-in-python-3-4/
edit.
I also added pdb - the python debugger
which you can then select by clicking the button above the run button:
before clicking run. You can set breakpoints in your code using the following snippet, where I have added DEBUG = 1 to the system environment in the run settings of the pdb run and DEBUG = 0 to the run python env:
if (QtCore.QProcessEnvironment.systemEnvironment().value("DEBUG") == "1"):
import pdb; QtCore.pyqtRemoveInputHook(); pdb.set_trace()
I am using the Command Prompt in Windows 8 to perform some analytical tasks with Python.
I'm using a few external libraries, some .py files with functions I need, and some set up commands (like setting certain variables based on databases I need to load).
In all there are about 20 statements. The problem is, that each time I want to work on it, I have to manually enter (copy/paste) all of these commands into the Shell, which adds a few minutes each time.
Is there any way I can save all of these commands somewhere and automatically load them into the prompt when needed?
Yes,
Save your commands in any file in your home directory. Then set your PYSTARTUP environment variable to point to that file. Every time you start the python interpreter it will run the commands from the startup file
Here is the link to example of such file and more detailed explanation
If you need to have different start up files for different projects. Make a set of shell scripts one per project. The scripts should look like this:
#!/bin/bash
export PYTHONSTARTUP=~/proj1Settings.py
python
And so on. Or you can simply change the value of PYTHONSTARTUP variable before you start working on a particular project. Personally, I use MacOS with Iterm2, so I set-up multiple profiles for different projects. When I need to work on a particular project I simply launch a tab with the profile configured for the project.
The Windows 7 Control Panel "Notification Area Icons" allows you to customize which system tray icons are visible. For each of the icons, it shows two things:
an application name
a subtitle
It looks like the subtitle comes from the tooltip text, because I can set that.
But what about the application name? I'm writing a GUI in PySide and can't figure out what incantations I need to do, to set this to something other than "python.exe".
python.exe will always show up if the module is run under the python executable, regardless of via a shortcut or not. It also shows up in task manager under the process name python.exe.
To circumvent this, it is necessary to create a custom executable to run the python script under it's own name. This doesn't have to be a monolithic exe packer such as py2exe, but can be something a little more discrete.
Using effbot.org's open source ExeMaker for instance, the following steps will result in what you want.
After downloading exemaker, simply run it from the command line with
exemaker scriptname.py
and it'll create scriptname.exe.
You may then run scriptname.exe by double clicking it, and it shall run the python script under it's own name.
The advantage of this small tool is that any changes made to the python script do not require recompilation of the exe - they are effective immediately.
This is because you are launching your application using Python.exe. In your case the main application running is Python.exe, so the Notification Area Icons will always show you Python.exe as running application.
When you are done with the development of your application, use pyinstaller or py2exe to package your application. After this process you will have a exe file for your application, when you will run your application, the name in the Notification Area Icons for your application will be same as you will set for your main window title.
I did not really test it but it may work. Create a link to your .py file and choose the name. If you run that link it should show the name of the link.
PS: On command prompt title bar it works fine
I created a script that will tell me what to wear in the morning based on the weather (i.e. rain slicker if it will rain, heavy jacket if it will be cold, etc). I have fairly basic programming experience with python and the script works perfectly, but I want to be able to create a file that I can just double-click from my desktop and the script will automatically run.
My goal is to be able to simply double click [something] in the morning and it will automatically run the script and thus tell me what to wear. How could I go about doing this?
System Specifications:
python
Mac OSX
This worked for me on Snow Leopard:
-Put the python script on the desktop.
-Right click on the script file, and choose "Get info"
-Find "Open With", and choose "Python Launcher" from the dropdown box
Now double-clicking the script file will run the script in a new terminal window.
I'm not sure what versions of OS X come with the Python Launcher application. If you don't have that, you can solve it with a couple extra steps:
-Put the python script anywhere
-Create a shell script on the desktop with one line:
python "/Users/john/scripts/what-to-wear.py"
(Where I've assumed your script is called what-to-wear.py and is in /Users/john/scripts. Be aware that you do need to use an absolute path.)
-Make the shell script executable. In a terminal:
chmod 755 what-to-wear-shell-script
-Double clicking the shell script should run it in a terminal, running your python script.
What you want to do is create an executable file.
I've never used a Mac or Python, but look at this question and the first answer:
How can I create a directly-executable cross-platform GUI app using Python?
Seems http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html is what you're looking for
Use a batch file to make it automatic
Example :
1. Open Notepad -> type the following.
This one's for Windows..It might give you a hint
:start
C:\Python34\python.exe(your python file location)Your *.py file location.
:end
Save this with a *.bat extension
That's it ..you can configure more on this batch,I guess batch is the automation for day to day script
In Linux/unix based OS , add #!/usr/bin/python3 line on top of your script file with extension .py , if you have python version 3. Or change it to the version installed in the machine
Further , make the file executable by
sudo chmod +x <fileName>
for windows, add windows python path and make the file executable
You want the script to download the weather information online and output the clothes based on your predefined rules?
If this is the case, use urllib to download the page and do some ad hoc parsing over the downloaded html page to get the whether information. And write your logic using nested IF THEN ELSE blocks.