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
|
import settings
|
||||||
from os import chdir
|
from os import chdir
|
||||||
import os.path
|
import os.path
|
||||||
@ -77,7 +77,7 @@ class History:
|
|||||||
db.commit()
|
db.commit()
|
||||||
except:
|
except:
|
||||||
db.rollback()
|
db.rollback()
|
||||||
raise
|
self.unlock_db()
|
||||||
finally:
|
finally:
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ class History:
|
|||||||
db.commit()
|
db.commit()
|
||||||
except:
|
except:
|
||||||
db.rollback()
|
db.rollback()
|
||||||
raise
|
self.unlock_db()
|
||||||
finally:
|
finally:
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ class History:
|
|||||||
db.commit()
|
db.commit()
|
||||||
except:
|
except:
|
||||||
db.rollback()
|
db.rollback()
|
||||||
raise
|
self.unlock_db()
|
||||||
finally:
|
finally:
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ class History:
|
|||||||
db.commit()
|
db.commit()
|
||||||
except:
|
except:
|
||||||
db.rollback()
|
db.rollback()
|
||||||
raise
|
self.unlock_db()
|
||||||
finally:
|
finally:
|
||||||
db.close()
|
db.close()
|
||||||
pass
|
pass
|
||||||
@ -142,7 +142,7 @@ class History:
|
|||||||
db.commit()
|
db.commit()
|
||||||
except:
|
except:
|
||||||
db.rollback()
|
db.rollback()
|
||||||
raise
|
self.unlock_db()
|
||||||
finally:
|
finally:
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
@ -155,10 +155,15 @@ class History:
|
|||||||
db.commit()
|
db.commit()
|
||||||
except:
|
except:
|
||||||
db.rollback()
|
db.rollback()
|
||||||
raise
|
self.unlock_db()
|
||||||
finally:
|
finally:
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
|
def unlock_db(self):
|
||||||
|
connection = dbapi2.connect(self._name)
|
||||||
|
connection.commit()
|
||||||
|
connection.close()
|
||||||
|
|
||||||
def messages_getter(self, tox_id):
|
def messages_getter(self, tox_id):
|
||||||
return History.MessageGetter(self._name, 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,
|
friend.name if data[1] == MESSAGE_OWNER['FRIEND'] else self.name,
|
||||||
data[0]))
|
data[0]))
|
||||||
s = new_line.join(arr)
|
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
|
return s
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
@ -1135,6 +1137,7 @@ class Profile(contact.Contact, Singleton):
|
|||||||
if not os.path.isfile(avatar_path): # reset image
|
if not os.path.isfile(avatar_path): # reset image
|
||||||
avatar_path = None
|
avatar_path = None
|
||||||
sa = SendAvatar(avatar_path, self._tox, friend_number)
|
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
|
self._file_transfers[(friend_number, sa.get_file_number())] = sa
|
||||||
|
|
||||||
def incoming_avatar(self, friend_number, file_number, size):
|
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 time
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
program_version = '0.2.5'
|
program_version = '0.2.6'
|
||||||
|
|
||||||
|
|
||||||
def log(data):
|
def log(data):
|
||||||
|
Loading…
Reference in New Issue
Block a user