updater.py and bug fixes
This commit is contained in:
parent
337601f2a1
commit
97ce2b9ceb
@ -1,4 +1,4 @@
|
||||
from sqlite3 import connect
|
||||
from sqlite3 import connect, dbapi2
|
||||
import settings
|
||||
from os import chdir
|
||||
import os.path
|
||||
@ -77,7 +77,7 @@ class History:
|
||||
db.commit()
|
||||
except:
|
||||
db.rollback()
|
||||
raise
|
||||
self.unlock_db()
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
@ -91,7 +91,7 @@ class History:
|
||||
db.commit()
|
||||
except:
|
||||
db.rollback()
|
||||
raise
|
||||
self.unlock_db()
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
@ -114,7 +114,7 @@ class History:
|
||||
db.commit()
|
||||
except:
|
||||
db.rollback()
|
||||
raise
|
||||
self.unlock_db()
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
@ -128,7 +128,7 @@ class History:
|
||||
db.commit()
|
||||
except:
|
||||
db.rollback()
|
||||
raise
|
||||
self.unlock_db()
|
||||
finally:
|
||||
db.close()
|
||||
pass
|
||||
@ -142,7 +142,7 @@ class History:
|
||||
db.commit()
|
||||
except:
|
||||
db.rollback()
|
||||
raise
|
||||
self.unlock_db()
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
@ -155,10 +155,15 @@ class History:
|
||||
db.commit()
|
||||
except:
|
||||
db.rollback()
|
||||
raise
|
||||
self.unlock_db()
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
def unlock_db(self):
|
||||
connection = dbapi2.connect(self._name)
|
||||
connection.commit()
|
||||
connection.close()
|
||||
|
||||
def messages_getter(self, tox_id):
|
||||
return History.MessageGetter(self._name, tox_id)
|
||||
|
||||
|
@ -554,6 +554,8 @@ class Profile(contact.Contact, Singleton):
|
||||
friend.name if data[1] == MESSAGE_OWNER['FRIEND'] else self.name,
|
||||
data[0]))
|
||||
s = new_line.join(arr)
|
||||
if not as_text:
|
||||
s = '<html><head><meta charset="UTF-8"><title>{}</title></head><body>{}</body></html>'.format(friend.name, s)
|
||||
return s
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
@ -1135,6 +1137,7 @@ class Profile(contact.Contact, Singleton):
|
||||
if not os.path.isfile(avatar_path): # reset image
|
||||
avatar_path = None
|
||||
sa = SendAvatar(avatar_path, self._tox, friend_number)
|
||||
sa.set_transfer_finished_handler(self.transfer_finished)
|
||||
self._file_transfers[(friend_number, sa.get_file_number())] = sa
|
||||
|
||||
def incoming_avatar(self, friend_number, file_number, size):
|
||||
|
25
toxygen/updater.py
Normal file
25
toxygen/updater.py
Normal file
@ -0,0 +1,25 @@
|
||||
import util
|
||||
import requests
|
||||
|
||||
|
||||
def check_for_updates():
|
||||
current_version = util.program_version
|
||||
major, minor, patch = list(map(lambda x: int(x), current_version.split('.')))
|
||||
versions = generate_versions(major, minor, patch)
|
||||
for version in versions:
|
||||
if send_request(version):
|
||||
return version
|
||||
return None
|
||||
|
||||
|
||||
def send_request(version):
|
||||
# TODO: proxy support
|
||||
request = requests.get('https://github.com/toxygen-project/toxygen/releases/tag/v' + version)
|
||||
return request.status_code == 200
|
||||
|
||||
|
||||
def generate_versions(major, minor, patch):
|
||||
new_major = '.'.join([str(major + 1), '0', '0'])
|
||||
new_minor = '.'.join([str(major), str(minor + 1), '0'])
|
||||
new_patch = '.'.join([str(major), str(minor), str(patch + 1)])
|
||||
return new_major, new_minor, new_patch
|
@ -2,7 +2,7 @@ import os
|
||||
import time
|
||||
import shutil
|
||||
|
||||
program_version = '0.2.5'
|
||||
program_version = '0.2.6'
|
||||
|
||||
|
||||
def log(data):
|
||||
|
Loading…
Reference in New Issue
Block a user