I'm asking a question about my Django application updates.
I'm working on my Django Development server and I would like to know How I could create a patch which will update my different Django Project installed on different servers.
For example :
In my Dev' server, I add a new Query in my script. Then I would like to add this new Query to my all virtual instances by updating my script and not just copy/past modifications. It could work for one query, but if I have 200 rows, copy/paste will be too long.
I launch a patch which will make all updates without manually copy/paste rows.
How it's possible to do that ?
Thank you so much
You should probably consider migrating your project to a version control system.
Then every time you are changing something to your local copy of the code and push the changes on the repository, you can fetch/rebase/pull your changes wherever you want (be it your server or another computer of yours), and your patches will be applied without copy/pasting!
Some version control systems to consider:
Git Lab allowing the creation of free private repositories
Github the "old reliable", but no free private repositories
Bit Bucket (don't use it myself but it is widely used!)
Good luck :)
Related
First off, I know similar questions have been answered, but I can't find any solutions for my particular constraints. If there is one, please point me to it.
I'm trying to start a django project. However, I can't run the development server. The problem seems to be the SQLite version. I have 3.7.17 installed, django requires 3.9 or later. So I need to upgrade it. The problem is I'm using one machine from many, used by multiple developers all working on different projects, but sharing the same global python packages. So whatever changes I need to make, need to be inside my venv. And I don't have root access on the machine. Also, I don't plan on using SQLite as the DB for the project, so if that means I can somehow bypass this requirement, that would be fine as well. However, I assume, in that case I'll need to somehow transfer the django admin app to my DB of choice as well?
Note: I'm quite new to web development or programming in general, so a dumbed down explanation would be greatly appreciated. Thanks.
I am currently working on a server API. Said API is used in a mobile app that is being developed, and thus I've set up a dev server on a VPS. The API server uses python/django/django-rest-framework.
I have two offices that I work at- one has my desktop workstation, and at the other I use a laptop. I commonly will move from one office to the other during the day.
I have followed the many tutorials that are out there for setting up PyCharm to use a remote interpreter, and to sync changes to a remote server. However this seems to be causing a bit of an issue for me- I have 3 different copies of my code that may or may not be synced. Specifically, the server will always have its code synced with the last machine to have updated files. For example:
Make a change to coolStuff.py using my desktop. Save the changes. This pushes the saved changes to the server via pyCharm.
Get called to the other office. Drive over, open up my laptop. Go to edit coolStuff.py, and not realize that I am now working on an old copy, potentially overwriting the changes I made in step 1.
To get around this, I've been committing all of my changes after step 1, then pushing them up to the repo. I then need to pull the changes to the laptop. However, there are times that the push or pull is forgotten, and issues arise.
Is there a better workflow, or tools within pyCharm that can automate a 2-way sync between a dev machine and the server? Alternatively, would it be bad practice to use a cloud storage/sync to keep everything syncd up? (e.g.- store my code directory on something like Dropbox or OneDrive). I figure there has got to be a better way.
I inherited an appengine coursebuilder project a couple months ago, and we've been trying to upgrade to a more recent version of coursebuilder. In order to do this, the first step is to download local version of the course.
Whenever I run appcfg.py download_app -A $projectID -V $versionNumber ./folderToSaveTo
It downloads a different version of the course, one that looks like an old test version with old placeholder text, all links to lessons set to private, etc.
When I look at the versions of the course in the appengine dashboard, there is only a single version, so I'm not sure what it's even downloading.
Alternatively, it was suggested I use the ETL tool provided with coursebuilder to download the files instead, but that had a bunch of other issues associated with it as well. Previously I had asked the question directly on the coursebuilder forum where the ETL tool was initially suggested.
Thanks in advance for any help,
-Tyler Nolan
appcfg's download_app will only look within the default module. You should check if there are any drop-downs in the Developers Console UI which will allow you to look into whether there are other modules.
gcloud preview app modules download on the other hand, does allow you to specify modules.
Hopefully this helps you find the "real version" of your app.
It's also possible that what you download is displaying default data because it's not being viewed in a manner which is properly connected to the database, so it falls back to look like that.
I have a Django 1.6 project (stored in a Bitbucket Git repo) that I wish to host on a VPS.
The idea is that when someone purchases a copy of the software I have written, I can type in a few simple commands that will take a designated copy of the code from Git, create a new instance of the project with its own subdomain (e.g. <customer_name>.example.com), and create a new Postgres database (on the same server).
I should hopefully be able to create and remove these 'instances' easily.
What's the best way of doing this?
I've looked into writing scripts using some sort of combination of Supervisor/Gnunicorn/Nginx/Fabric etc. Other options could be something more serious like using Docker or Vagrant. I've also looked into various PaaS options too.
Thanks in advance.
(EDIT: I have looked at the following services/things: Dokku (can't use Heroku due to data constraints), Vagrant (inc Puppet), Docker, Fabfile, Deis, Cherokee, Flynn (under dev))
If I was doing it (and I did a similar thing with a PHP application I inherited), I'd have a fabric command that allows me to provision a new instance.
This could be broken up into the requisite steps (check-out code, create database, syncdb/migrate, create DNS entry, start web server).
I'd probably do something sane like use the DNS entry as the database name: or at least use a reversible function to do that.
You could then string these together to easily create a new instance.
You will also need a way to tell the newly created instance which database and domain name they needed to use. You could have the provisioning script write some data to a file in the checked out repository that is then used by Django in it's initialisation phase.
What is the best method to push changes to a program written in Python? I have a piece of software that is written in Python that will regularly be updated. What would be the best way to do this? All the machines will have Windows 7.
Also, excuse the ambiguity of my question. This will be my first time having to implement an updating procedure. Feel free to mention specifics you would like me ot add.
If you're not already packaging your program with InnoSetup, I strongly recommend you switch to it, because it has facilities to make this sort of thing easier. You can specify any special situations, such as files that should not be updated if they already exist (i.e. if you have any internal configuration files or things like that), in the InnoSetup script.
Next, to allow the client machine to find out about new versions of your app, keep a very small file on your public web server that has the version number of the current release and the URL to the latest version's installer exe. For this file to be useful, whenever you release a newer version of your program you must update this file, as well as the version number in the InnoSetup script, and also some kind of APP_VERSION constant in your program.
Then, you'll need to handle these parts of the updater yourself:
Detecting when a newer version is available by retrieving the current-version file from your web server over HTTP, and comparing the version number there to the app's own APP_VERSION. Make sure to do this query in a way that fails gracefully if the client machine doesn't have Internet access, and that doesn't block the GUI while it is doing the request (in case there's a network issue that forces the query to wait a long while for a timeout).
If a newer version is available, asking the user if they want to update, and if they say yes downloading an updated installer to the TEMP directory. Depending on what GUI toolkit you are using, there are various mechanisms for displaying a progress dialog during the download; this is a good idea since the installer is likely to be at least an MB.
Closing your app, running a special update script in the background, then starting up the app again.
The update script will wait for the original process to die completely (easiest way to do this is to pass in the original process's PID as a command line argument and have the update script send a query signal 0 to that process every second or so until it goes away.) It can then run the installer silently in the background, perhaps while displaying a "Please Wait..." dialog to the user. Once the installer is done and reports success in its return code, the updater can restart your program.
Depending on how big your app is, this is more wasteful of bandwidth than the method using git or another SCM. Every update with this approach would involve downloading the entire installer for the latest version of the app, whereas an SCM would only download the files that have changed. However, it has the advantage that it requires no special server facilities except a regular web server, and no special installation of the SCM client on the user's computer.
Plus, InnoSetup is just generally cool. :-)
I would suggest using a source control program such as git or subversion. Also, if you are okay with everyone seeing the code, you can post the code on github, where anyone can pull from it. You could make it private, but you would have to pay for it and all the users would also have create a github account and set it up with their git install.
If you use a source control program, the other people will have to pull the edits manually by running a command, but you could make a script pr batch file that does this and have it run at start up or at regular intervals.
Just to be clear, if you want to do this, you will have to put the code on a server with and SSH support and set up git. If you don't want to go through all of the server set up, I would reccomend github.
git- http://git-scm.com/ (For windows version, go to downloads and select msysGit)
github - https://github.com/
For those of you that would be looking into something a little less dated, I was just looking at how to create python applications that can be updated remotely (though not limited to Windows like OP).
It seems like esky as been a solution for a while. Though it's been deprecated since 2018.
The latest and most up to date solution seem to be a combination of pyinstaller and pyupdater. Note that I don't have personal experience with it, I'm looking for a friend.
It seems to support windows, linux and Mac though and both python 2 and 3 so definitely worth having a look.
The basic principles of application updates are described well by DSimon's answer.
However, update security is a different matter altogether: You don't want your clients to end up installing malicious files.
PyUpdater, as suggested in jlengrand's answer, does provide some secure update functionality, but, unfortunately, PyUpdater 4.0 is broken and there has not been a new release in over half a year (now Aug 2022).
There's also python-tuf, which is the reference implementation of The Update Framework (TUF).
TUF (python-tuf) does everything humanly possible to ensure your update files are distributed securely. However, it does not handle application-specific things like checking for new application versions and installation on the client side.