From 2ca8cf73a3076852d40fa48b20a6e740bd9feb72 Mon Sep 17 00:00:00 2001 From: Sa'ar Date: Fri, 29 Sep 2017 17:10:13 -0700 Subject: [PATCH 1/5] Create comments.py --- comments.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 comments.py diff --git a/comments.py b/comments.py new file mode 100644 index 0000000..6f0d043 --- /dev/null +++ b/comments.py @@ -0,0 +1,7 @@ +from tkinter import * +import sqlite3 + +class Comments: + def __init__(self): + login = sqlite3.connect("login.db") + comments = sqlite3.connect("comments.db") From b113e5657380582aa48d0363aecda701d4448d9a Mon Sep 17 00:00:00 2001 From: Sa'ar Date: Sat, 30 Sep 2017 13:50:39 -0700 Subject: [PATCH 2/5] Delete comments.py --- comments.py | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 comments.py diff --git a/comments.py b/comments.py deleted file mode 100644 index 6f0d043..0000000 --- a/comments.py +++ /dev/null @@ -1,7 +0,0 @@ -from tkinter import * -import sqlite3 - -class Comments: - def __init__(self): - login = sqlite3.connect("login.db") - comments = sqlite3.connect("comments.db") From 8f0682fa325dd0f697cb8867790d0c0eea5ceed7 Mon Sep 17 00:00:00 2001 From: Sa'ar Date: Sat, 30 Sep 2017 13:56:37 -0700 Subject: [PATCH 3/5] Create handlers.py --- handlers.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 handlers.py diff --git a/handlers.py b/handlers.py new file mode 100644 index 0000000..1f3c956 --- /dev/null +++ b/handlers.py @@ -0,0 +1,51 @@ +import sqlite3 +import smtplib + +class UserError(Exception): + pass + +class SqlHandler: + def __init__(self): + self.connection = sqlite3.connect("comments.db") + self.cursor = self.connection + + cmd = """ + CREATE TABLE IF NOT EXISTS users ( + id INTEGER PRIMARY KEY, + username TEXT + email TEXT + password TEXT);""" + + self.cursor.execute(cmd) + + cmd = """ + CREATE TABLE IF NOT EXISTS comments ( + id INTEGER PRIMARY KEY, + senderId INTEGER + comment TEXT);""" + + self.cursor.execute(cmd) + + def login(self, username, password): + cmd = "SELECT * FROM users WHERE ((username = {0} OR email = {0}) AND password = {1});".format(username, password) + self.cursor.execute(cmd) + user = self.cursor.fetchone() + try: + assert user != None + except AssertionError: + raise UserError("While logging in: Username or password not correct.") + return user + + def signup(self, username, email, password): + cmd = "SELECT * FROM users WHERE (username = \"{0}\" OR email = \"{1}\");".format(username, email) + self.cursor.execute(cmd) + try: + assert user == None + except AssertionError: + raise UserError("While signing up: User with username or email already exists") + return False + cmd = "INSERT INTO users VALUES(NULL, {0}, {1}, {2});".format(username, email, password) + + def sendComment(self, senderId, comment): + cmd = "INSERT INTO comments VALUES(NULL, {0}, {1});".format(senderId, comment) + self.cursor.execute(cmd) From b752b7d369b940cae6a654c182f0f0973158d005 Mon Sep 17 00:00:00 2001 From: Sa'ar Date: Sat, 30 Sep 2017 13:57:06 -0700 Subject: [PATCH 4/5] Delete handlers.py --- handlers.py | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 handlers.py diff --git a/handlers.py b/handlers.py deleted file mode 100644 index 1f3c956..0000000 --- a/handlers.py +++ /dev/null @@ -1,51 +0,0 @@ -import sqlite3 -import smtplib - -class UserError(Exception): - pass - -class SqlHandler: - def __init__(self): - self.connection = sqlite3.connect("comments.db") - self.cursor = self.connection - - cmd = """ - CREATE TABLE IF NOT EXISTS users ( - id INTEGER PRIMARY KEY, - username TEXT - email TEXT - password TEXT);""" - - self.cursor.execute(cmd) - - cmd = """ - CREATE TABLE IF NOT EXISTS comments ( - id INTEGER PRIMARY KEY, - senderId INTEGER - comment TEXT);""" - - self.cursor.execute(cmd) - - def login(self, username, password): - cmd = "SELECT * FROM users WHERE ((username = {0} OR email = {0}) AND password = {1});".format(username, password) - self.cursor.execute(cmd) - user = self.cursor.fetchone() - try: - assert user != None - except AssertionError: - raise UserError("While logging in: Username or password not correct.") - return user - - def signup(self, username, email, password): - cmd = "SELECT * FROM users WHERE (username = \"{0}\" OR email = \"{1}\");".format(username, email) - self.cursor.execute(cmd) - try: - assert user == None - except AssertionError: - raise UserError("While signing up: User with username or email already exists") - return False - cmd = "INSERT INTO users VALUES(NULL, {0}, {1}, {2});".format(username, email, password) - - def sendComment(self, senderId, comment): - cmd = "INSERT INTO comments VALUES(NULL, {0}, {1});".format(senderId, comment) - self.cursor.execute(cmd) From a856d1e086bd738e2e6362cd69ce6852f1e0fd9e Mon Sep 17 00:00:00 2001 From: Sa'ar Date: Tue, 3 Oct 2017 18:18:24 -0700 Subject: [PATCH 5/5] Create setup_app.py --- setup_app.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 setup_app.py diff --git a/setup_app.py b/setup_app.py new file mode 100644 index 0000000..b6eee4a --- /dev/null +++ b/setup_app.py @@ -0,0 +1,28 @@ +from setuptools import setup + +APP = ['mainloop.py'] +APP_NAME = "LearnPythonWithPython" +APP_IDENTIFIER = "com.saardeveloper.python-with-python" +APP_VERSION = "1.BETA.2" +APP_VERSION_SHORT = "Beta 2" +MODULES=['window', 'screens'] +DATA_FILES = [] +OPTIONS = { + 'argv_emulator': True, + 'plist': { + 'CFBundleName': APP_NAME, + 'CFBundleDisplayName': APP_NAME, + 'CFBundleIdentifier': APP_IDENTIFIER, + 'CFBundleVersion': APP_VERSION, + 'CFBundleShortVersionString': APP_VERSION_SHORT + } +} + +setup( + name=APP_NAME, + py_modules=MODULES + app=APP, + data_files=DATA_FILES, + options={'py2app': OPTIONS}, + setup_requires=['py2app'] +)