How do I use bugzilla's webservice xml-rpc with python? - python

I need to know how to log into bugzilla using python. I have no idea where to start. The only requirement I got is that I have to use bugzilla's webservice xml-rpc. I also have no experience with python. So could anyone tell me the basic steps I need to take to import bugzilla using python? Thanks.
I have python installed on linux and can run code like print "hello world!". But I did not download any additional plugins.
Do I need this plugin: https://pypi.python.org/pypi/python-bugzilla/1.1.0?

Finally figured it out:
bz = bugzilla.Bugzilla(url='https://bugzilla.redhat.com/xmlrpc.cgi')
bug = bz.getbug(495561)

Related

OpenApi for Python

I'm trying to use OpenAPI for a Python project.
I've previously used OpenAPI with Java and it was really easy as you could configure it into pom.xml so that you would write a yaml file and then you would get an interface that you could implement into your controller.
I'm now working in Python and I'm trying to do a similar thing where you write an yaml file and get an interface or something similar that you can use.
I've tried openapi-generator-cli generate but it seems like it creates a lot of bloat files as it creates the whole server but I only need a single file that I can use further.
Is there something similar for Python as it is for Java?
Thanks in advance
You may want to try import flask_restx.
Then visit top-level URL of your flask app to see the swagger details.
https://flask-restx.readthedocs.io/en/latest/swagger.html#swaggerui
EDIT
Consider using apispec.
$ pip install -U 'apispec[yaml]'
can try flask-toolkits link very easy to setup as it will generate your openapi/swagger spec. Once you already done your code can try with app.run() then access http://localhost:5000/openapi.yaml

Unable to run Python on a hosted server

I am trying to run python on a hosted server. I'm using a Strato server.
The problem I have is that, when I run my Python code, it uses the Python 2.7 version - as it is set the default, and I've installed my python libraries in Python 3, so it shows an "500 Internal Error".
I tried to change the python path at the beginning of my python file to the Python 3 location, but it didn't work.
So, my question is, how can I run Python 3 (and not python 2) when opening the file?
Here's my code:
#!/usr/bin/python3
import requests
print("Content-Type: text/plain;charset=utf-8")
print()
print("Hello World!")
EDIT: I looked into the question that Maurice suggested, and checked my logs. As I supposed, the error says "No module named 'requests'", but I have it installed in Python 3, so it doesn't solve the problem
If you have python3 installed in the server, you can run using python3 [filename] instead of python [filename].
This points to the python3 that is installed in the machine and should give you the correct behaviour.
Edit:
Oh, got it. I don't know if Stratos servers have a special feature for running python scripts remotely like you are trying.
I see that you have a php background where it can be done easily, but to do it with python you would need to create a web API in order to expose your code on the web.
The most simple way to achieve this is using Flask. Flask is a simple web framework that allows you to expose your code like you are describing.
You can check the documentation here. Also, you can use this tutorial to implement the API.

Is there a way to compile python code in flutter apps itself?

Is there a way to compile python code in flutter apps itself ?
Note :- I did a bit of research and ended up with solutions which
wanted a dedicated server for python code to be hosted and later on I
could pass a query and get response which is not exactly I am aiming
for. Please help 🙂
Awesome So I came up with a solution for which we need to use a package named Starflut.
Just read the documentation on the first page of the package and you will understand how to implement it!
Link :- Starflut
Happy Coding ! 😉

Is there a way to determine if my code is run in an embedded Python?

So we're developing a C++ Python application that is both used in native Python and also in a embedded Python version that is wrapped in R using reticulate. Now we want to determine whether the currently running Python is in embedded mode or not.
Does anyone know what I could do here? I have not found any documentation about different env setups or internal hints that I could use to find this information within Python. We would have to determine on the Python side and not the C++ side...
I appreciate any hint I could get!
Edit about environments:
The main problem is that we use an embedded Python version with our R application and a native Python version with our main application. So our clients can access the same code snippet from basically any Python version that is included in the PY_LIMITED_API. So if I recall it correctly thats any version 3.2+
I haven't answered my question until now.
My workaround was a simple
try:
import pip
except ImportError:
PythonIsRunEmbedded = True
Since pip is not included with the embedded version of Python

Connecting to Sql Server with Python 3 in Windows

Can someone please point me in the right direction of how I can connect to MS SQL Server with Python? What I want to do is read a text file, extract some values and then insert the values from the text file into a table in my Sql Server database. I am using Python 3.1.3, and it seems some of the modules I have come across in research online are not included in the library. Am I missing something? Is there a good 3rd party module I should know about. Any help would be greatly appreciated.I am using Windows. thanks
There are a bunch more SQL Server libraries listed on the Python wiki. At least mxODBC is fully ready for Python 3.1, but I haven't used it so I can't comment on its appropriateness...
There is a pymssql module. Here you can find installation instructions
I found a module called CEODBC that I was able to use with Python 3 after doing some research. It looks like they will also be releasing a Python3 compatible version of PYODBC soon. Thanks for all your help.

Categories

Resources