Deploying a python cloud service/webjob to Azure via GIT - python

I'm trying to find a way to bind my cloud service or webjob to GIT.
I've tried following this guide
Everything worked well - the files were uploaded and a build job was initiated on the server, BUT I keep getting the following error:
C:\a\src\AzureCloudService1\Crawler\Crawler.pyproj (48, 0) The
imported project "C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v12.0\Python
Tools\Microsoft.PythonTools.Worker.targets" was not found. Confirm
that the path in the declaration is correct, and that the
file exists on disk.
I've searched this problem and based on suggestions I've found I uploaded the missing files and changed the location that points to them.
The above missing files were then read successfully but they're trying to use other files as well, which can't be found for the same reason.
Shortly, I get a chain of "not found" files.
I'm out of ideas, will appreciate your help.

Your issue is little relationship with Azure Could Service deployment, it’s the limitation of VSO building process. The VSO uses MSBuild to check code and build project, and which is lack of python tools dependence on VSO server. Here is the same issue with you and explained by VSO engineer. I’d like to quote a paragraph of this communication:
VSO Build preview is going to be able to better support non-.NET projects, and explicit support for Python projects will come eventually but is already available through command-line options. Getting Cloud Service projects changed to work better is more difficult (I don't even have a good contact for that team right now). Our own team also has conflicted priorities, and right now we've got everyone focusing on fixing crashes and issues that affect most of our users - working around Cloud Service's lack of extensibility is one of the (many) things that gets pushed down the list.
Currently, we can publish Cloud Server to Azure directly in Visual Studio as a workaround.
For more details, please read Python web and worker roles with Python Tools 2.2 for Visual Studio

Related

How to sync python files from PyCharm IDE to GitHub Automatically?

I'm currently using PyCharm IDE to learn Python. I am not aware of how to sync my file automatically to GitHub. Or to be precise I want my code to automatically sync as I type, to my GitHub repo. Like I want the file to exist in GitHub and edit it over my IDE.
Is there any solution for this to happen?
Regards,
Kausik
That is not how git (or Github) works. Version control systems are designed to capture milestones in your project. I think you're confusing git with file management cloud services (e.g., Dropbox or Google Drive). If you need something that would sync your files with each "save" you make to a file then services like Dropbox are what you looking for.
However, version control systems (e.g., git) are much better suited for code management if you adjust your workflow to follow how they were intended to be used. In PyCharm, after each milestone (e.g., a bug fix or a new feature implementation) you would do the following:
Stage changed files by checking them.
Commit the changes by adding a commit message.
Push changes to the remote repository.
All these can be found within the Commit window in PyCharm (View >> Tool Windows >> Commit). All the three steps above can be done in one click
One last thing. If your goal is to collaborate with someone else in real-time, then PyCharm has a new feature called "Code with me" (Tools >> Code With Me ...). I don't know if it is available for free but the idea is that you would invite friends and change the code base together in real-time. And eventually, you would push the changes to the remote repository.

Uploading images to a windows server using python

thanks in advance
I have a nginx server in which i am running python tornado application server. My tornado server conatins api endpoints(Handler), Models (DB table models) and the code for their respective services. We are using it as a backend service for an app that sells goods. Recently, we have implemented a complain feature that lets you upload image for the products.
I have to write code in python to convert base64 image into actual jpg/png (which is done), and then upload it to a different windows server(i m stuck in uploading part). I have been researching about it and found a few ways like
FTP
by RemoteDesktopConnection (it is clearly not for me)
and a few more.
if there is any better way to do this plz tell. i am not really experienced so plz explain your answers in a bit detail. Thank you for your time.
previously i was storing it in my application server which is clearly not a good thing to do and i was not able to expose the url for images also.
If it just needs to be a file in a directory on the other windows server, one could turn on file sharing for the specific directory on the other windows server and then smb mount that directory onto your application server. Then your python code could simply write a file to that directory.
A fairly good guide for doing this can be found here
Note that in a final production environment you want to be sure that the security is set appropriately (which is beyond the scope of this question).

How to upload files to onedrive using msgraph-sdk-python?

I'm not a newbie when it comes to python (nor a professional), but this is the first time I'm trying something like this.
I would like to upload files to OneDrive using an python script. Sounds simple right? Well apparently it's more then I can handle.
From what I've seen so far the onedrive-sdk-python I was using apparently doesn't work anymore (source: https://github.com/OneDrive/onedrive-sdk-python/issues/119) because it's being decommissioned.
The new SDK to use is the one for Microsoft Graph I guess? But the github (https://github.com/MicrosoftArchive/msgraph-sdk-python) doesn't really mention how to set up the new Oauth2 authentication, get a token and use the client in python. The links mentioned in the authentication section don't work for me, I get error messages like: "AADSTS900144: The request body must contain the following parameter: 'client_id'."
I looked on stackoverflow for similar questions but most of them are about the old onedrive-sdk and the most recent one I could find was almost 3 months old. The response there was that it was still under development.
I guess the problems I've been having are all related to the Microsoft Graph still being in development, but I was wondering if someone managed to get it to work and if they could point me in the right direction to get the authentication setup and getting me started on uploading files to OneDrive.
Some details in case it matters:
Rasbian 9 Stretch
Python 2.7.13 & Python 3.5.3 (tried both)
OneDrive business account
Many thanks to anyone who can point me in the right direction :)
I'm afraid the SDK you're using is no longer being actively maintained. From the ReadMe:
This library is no longer actively supported. To integrate Microsoft Graph into your Python solution, we recommend using REST and taking a look at our new Python samples and documentation.
To answer your question on tokens, these are not technically issued by Microsoft Graph. They're issued by Azure Active Directory (or Outlook.com for personal accounts). You obtain a token using OAuth 2.0.
You are, however, on the right track. Before you can do anything with Microsoft Graph, you're going to need to obtain an OAuth token. The good news here is there's a sample Python project that walks you through how this process works: Python authentication samples for Microsoft Graph.

Getting push to deploy to work, configuring "release pipeline"

So since last week suddenly git push origin master doesn't work anymore to "push to deploy". It sure pushes the sources to remote repository at Google, and the code is there but it never deploys. Read about it here: GAE: Trouble with push to deploy
It seems things are changing over at Google and this week there is new stuff in the Google Developer Console, in the "Cloud Development/Releases" section; "Configure Release Pipeline"
There are three settings: the pipeline name, pipeline tasks, and then an optional setting to have deploy notifications sent by email.
I just enter a random name like "mydevpipeline", select "Deploy source only", and check the email box. But I just get this error: "Failed to create the pipeline.". I also tried unchecking the email box, still same error. Tried it over and over.
No where to go from there...
Anyone been able to create this pipeline and get it all working?
It seems that this pipeline configuration must go through in order for push to deploy from now. I haven't seen any news or notification about this change...
Fwiw, the documentation https://developers.google.com/appengine/docs/push-to-deploy states nothing about pipelines. It's just outdated I guess.
Update:
What do you know... I went on trying to configure this pipeline on the live GAE project (the one described above is the dev GAE project I'm using)... and it worked. I could configure a pipeline ok. After that, I could once more push-to-deploy, alas only on the live version so far. I might try creating a new dev project, it seems existing projects "break" from time to time... I have had similar problems before and creating a new project DOES solve things from time to time.....
Google App Engine pipelines do not like .gitignore file. Try if it works without that file. It fixed the problem for me.
It took me a long time to get this working for PHP, after a lot of communication with Google it was finally revealed to me that in your app.yaml file you need to have a line that reads:
threadsafe: false
In order for the pipeline to successfully pick up and deploy your git push (I use sourcetree, but command line git has the same end result) that line must be present. If it's omitted or set to true the pipeline won't be able to deploy it.
I wanted to throw this answer on here in case anyone stumbled on this thread looking for help. One of my projects has "randomly broken" and after 3 months of successfully using my release pipeline for multiple commits per day it suddenly no longer deploys when I push. Ultimately giving the extremely helpful error message of "Unable to get deployment status" - and now none of my changes can be applied to the live site. Copying the entire source code, changing the app name, and pushing to a new GAE project with release pipeline works fine, but I need the original site to start working again.

Installing Sphinx on App Engine - possible?

Following up on my last year's question on documentation, I now want to get started and try out Python-based Sphinx for putting together the developer documentation for a PHP CMS I've been working on.
Instead of setting up Python locally on my workstation, I would like to run it on a publicly accessible web server from the start. All the web hosting packages I have access to run on the LAMP stack, and I'm reluctant to buy Python-based hosting. I am very interested in the Google App Engine, the free quotas they provide will do for me a hundred times over, and even if not, their pricing looks very reasonable.
Now I have zero knowledge of Python - getting Sphinx to work would be my first contact with it - and very little time. As far as I understand, the platform and python libraries the App Engine provides are very compatible to a standard Python library but not identical.
So my question is:
Can Sphinx run on App Engine at all?
Is installing Sphinx on the App Engine as straightforward as if I would install it on top of a normal Python installation? Or will the App Engine's environment require tweaking of the source code that I can't perform in reasonable time with my current level of Python?
Should I be installing Sphinx on a local server and a "normal" Python stack instead first?
Does anybody know any helpful How-to's, tutorials or other resources for this?
You do not need to install Sphinx on GAE at all.
You use Sphinx to create a directory of static HTML, CSS and JS. When this step is finished, you simply upload the output from Sphinx -- in it's entirety.
The output from Sphinx (HTML, CSS and JS) is simply served from one place. You upload the documentation from where you created it to GAE as static files and serve them. Done.
There's no "install on a web server" aspect to Sphinx at all. Sphinx is not a web application; it does not run on your web server. You run it in development briefly to publish the documentation to HTML, LaTeX or whatever. Once you've created the static HTML files, you no longer need any part of Sphinx anywhere.
Can Sphinx run on App Engine at all?
I suppose it can, but you never need to.
Is installing Sphinx on the App Engine
as straightforward as...
It doesn't matter, because you don't install it there. You install it on your workstation and use it on your workstation.
Should I be installing Sphinx on a
local server and a "normal" Python
stack instead first?
Don't install it on a server. Install it on your workstation.
Does anybody know any helpful
How-to's, tutorials or other resources
for this?
If by "this" you mean "installing on a web server", then then answer is "no". One does not install it on a web server. So there are no how-to's, tutorials or resources for "installing on a web server".
If by "this" you mean "creating documentation with Sphinx", then the answer is "what's wrong with https://www.sphinx-doc.org? What do they lack?
I would like Sphinx's "engine" that
turns the input (consisting of reST
files) into HTML/CSS/JS to be
accessible from anywhere to make me
(and possible other contributors)
independent from a specific
workstation.
Sphinx is like a compiler. Everyone has their own copy on their workstation. They download the document source, make changes, commit the source changes, and upload the resulting document.
serve the generated documentation from
the same place.
Correct. After you download the source, make changes, regenerate the document and commit the changes, you upload the resulting document so it will be served from one -- and only one -- place.
Sphinx is a compiler. It is not a "web engine". It's a simple compiler that simply compiles your documentation into HTML so it can be served.
Interesting project! The main issue you're going to run into is that of filesystem access: The filesystem on App Engine is read-only, and based on looking at the source, Sphinx is fairly hard-coded to use the filesystem for output. It also expects to read the configuration file and input files from the local filesystem, which would make building docs for anything other than projects bundled with the app tricky.
It is possible to work around this, but it would require writing a simple virtual filesystem that uses the App Engine datastore, and using monkeypatching to make it work with the regular Python file interface. That's rather advanced for a "new to Python" project!
One other thing you might want to consider if you were pondering allowing users to upload projects to be documented: The Sphinx configuration file is in Python, so executing it could be dangerous - a user could do nasty things to your app with a malicious configuration file!
The difference between deployment locally via dev_appserver and remotely via appcfg has been - in my experience - limited to which of the two commands I execute. That said, I've no experience with Sphinx.
Sphinx compiles documentation, running it on a webserver makes as much sense as running gcc on a webserver.

Categories

Resources