could not save preference file google-apps-engine - python

Just installed Google Apps Engine and am getting "could not save" errors.
Specifically if I go in to preferences I get
Could not save into preference file
C:\Usera\myname/Google\google_appengine_launcher.ini:No such file or directory.
So some how I have a weird path, would like to know where and how to change this. I have search but found nothing, I have done a repair reinstall of GAE
Can find nothing in the registry for google_appengine_launcher.ini
I first saw the error when I created my first Application
Called hellowd
Parent Directory: C:\Users\myname\workspace
Runtime 2.7 (PATH has this path)
Port 8080
Admin port 8080
click create
Error:
Could not save into project file
C:\Users\myname/Google\google_appengine_launcher.ini:No such file or directory.
Thanks

I think I have found the answer to my own question.
I have a small app I have written to backup my stuff to Google Drive, this app would appear to have an error in it that does not stop it from running but does cause it to make a file called
C:\Usera\myname\Google
Therefore GAE can not create a directory called C:\Usera\myname/Google nor a file called C:\Usera\myname/Google\google_appengine_launcher.ini
I deleted the file Google, made a directory called Google and ran the GAE, saved pereferences and all working

Related

I'm trying to upload the bot to heroku server, I get this error:

I can't solve this problem, could it be my mistake?
Errors:
My files:
Your screenshot shows a file that appears to be called parser_twitter, but Windows recognizes it as a Python file. Similarly, chromedriver doesn't have a visible extension, but Windows recognizes it as an executable.
This suggests that Windows Explorer is hiding known file extensions. Those files are almost certainly really named parser_twitter.py and chromedriver.exe.
But your requirements.txt and runtime.txt file extensions are visible. That would mean they are actually called requirements.txt.txt and runtime.txt.txt.
I suggest turning off that "feature" so you can see what your files are actually called:
In File Explorer under View, in the Show/hide group, select the File name extensions check box.
Rename those files to remove the duplicate file extensions, commit, and redeploy.
Aside: If you have committed the chromedriver.exe file you're going to find that it doesn't work on Heroku. See Selenium web driver can't open browser on Heroku, for example.
Did you add the Python buildpack on your app? You can try checking it on the site or just run $ heroku buildpacks -app <your app name> if its not in there add it by running $ heroku buildpacks:set heroku/python -a <your app name>

Saving a html file to public_html

I have a small Flask application that runs fine locally, however when I go to run the application on my server, it runs but I am not able to get the output to save to a public_html folder.
This is the area I believe I am having the issue, when I run the application remotely:
df.to_html('/home/mydomain/public_html/data/candles.html', index = False)
If I run the application locally, this location works fine:
df.to_html('candles.html', index = False)
I have ensured that the remote folder 'data' has full access - 0777.
What am I doing wrong?
If you don't have an exception occurring, then very likely the file was saved, but not where you think it should have. If you did not provide a full path, the destination will be relative to the application directory. The solution is to be explicit and provide a full path, unless you are using some Flask functions that already have a default setting.
You should never grant 0777 permissions on public_html, that is a potential vulnerability. For example, someone could upload a shell to that directory if they can leverage a security flaw on your website.
There is not enough context, but the user running the process (Apache, Nginx or whatever) should not have write permissions here. If you must grant write permissions, create a dedicated directory (preferably outside the webroot unless they have to be exposed to the user), then add some directives to stipulate that files present in the directory cannot be executed. So that even if a webshell is uploaded it cannot run.

wkhtmltopdf not creating pdf in Heroku

I have a Python Flask project that uses the pdfkit module (and by extension wkhtmltopdf) to convert a locally stored HTML file into a .pdf file.
I have the whole thing working perfectly when it is hosted locally on my windows computer.
However after uploading my project folder to a Heroku instance and testing it - I received two errors (one of which I solved) when running through the program.
Note that I included wkhtmltopdf into my build pack before creating the Heroku instance with the following commands in Git (These were taken from Method 2 in: https://razorjack.net/wkhtmltopdf-on-heroku-evaluating-different-installation-options/):
I'll display them here as well:
heroku buildpacks:add https://github.com/dscout/wkhtmltopdf-buildpack.git
heroku config:set WKHTMLTOPDF_VERSION="0.12.4"
The first error that I solved involved pdfkit not being able to find the wkhtmltopdf binary in the Herkou instance. I eventually found it placed in the bin folder of my project - I added this to the pdfkit configuration path in my python file.
The problem that I'm now having is that the wkhtmltopdf/ pdfkit says it has created the .pdf file (I can see this from the output of the log tail on Git) but when I check the directory in the project folder on Heroku using the Heroku Terminal the .pdf doesn't appear to exist.
Interestingly when I try to 'touch' or create a new file in the /app folder in the instance nothing appears. But when I do the same in the /tmp folder it does. I have tried to point the wkhtmltopdf file.pdf creation to the /tmp folder but once again nothing appears to have been created.
If anybody could give me any helpful insight or a solution to why I might be having this problem I would be very grateful.
Thanks.
The problems you are facing may be caused by Heroku's ephemeral file system. Maybe this page of docs will help you find the solution.

Run local python script from Google Apps Script

As the title suggests, I'm looking for a way to run local python scripts from the Google Apps Scripts environment. Right now my method is to write a json file from app scripts and save it to a Google Drive directory. The local machine polls the directory via Google Drive File Stream, and runs the necessary code when the file appears in the directory. Not pretty, but it gets the job done. The main concern with this is that File Stream can be fairly latent - could be up to 15 minutes after a file is put in the directory before File Stream catches it and syncs the local machine.
Is anybody aware of other options? I could try re-writing the python code in Apps Script, though the python code relies on a few third party libraries that aren't available in JS. Another idea is setting up a flask server, but that seems like a good bit of work for the return.

How To Keep My File Paths Congruent for My Django/Python Application

I am developing a Django app on my Personal Computer. I have my files uploaded to a private repository on GitHub and I am using that to pull them down to my production server.
My question is this
I have file paths set inside of my application on my PC to file locations that are on my PC. But I also have those same files being uploaded and pulled onto my Production Server, but then needing to change the file path on my Production Server side application files in order to match the actual location on my Production Server
I have searched far and wide and cannot seem to find a proper solution to this. Is there some type of way I can write out the paths so that when I use an sys.path.append I don't have to give out the complete path, but rather a local one, so that it matches on both servers?
Possible Findings
Is there an issue if I just use sys.path.append('./<directory>')? This is, of course, assuming that the Python file is running within that current directory.

Categories