0
1

More than 3 years have passed since last update.

Qt for Python アプリの自己アップデート

Posted at

備忘録かつ添削をお願いしたく。

パッケージ化しないアプリでも、アップデートする仕組みを入れておかないと、修正する度にそれぞれのマシンでコピーする作業が起こってしまう事に気が付きました。
http経由でダウンロードする事も、zipファイルを展開することも簡単にできてしまうのだから、それを組み合わせてアプリケーションディレクトリのの .py ファイルを更新してやればよいのでは?ということで、当該の部分はこのようになりました。


    def updateDownloadQuit(self):
        url ="http://〜〜"
        title = './update.zip'
        urllib.request.urlretrieve(url,"{0}".format(title))

        QMessageBox.information(None, "Info",  "アプリケーションを更新して、終了します")
        with zipfile.ZipFile('update.zip') as existing_zip:
            existing_zip.extractall('.')

        MainWindow.close()

Qtでなくても、ちょっとしたスクリプト群の配布に使えると思います。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1