Commit 6c31617e authored by Shashank Kumar's avatar Shashank Kumar

Kivy Upgrade

- Kivy upgraded to 1.10.1
- Alternative script to `garden install` created in
`settings` module
parent d6b46042
# Python
*.pyc
/libs/garden
# For Tests
.pytest_cache
.coverage
......
......@@ -5,13 +5,15 @@ before_script:
- apt-get update -qy
- apt-get install -y python3 python3-dev python3-pip build-essential ffmpeg libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev zlib1g-dev
- apt-get install -y libgstreamer1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good
- apt-get install ffmpeg
- apt-get install -y ffmpeg git
- pip3 install pipenv
- pipenv install --dev --skip-lock
- pipenv install --skip-lock
- pipenv install --skip-lock git+http://github.com/kivy/kivy.git#egg=kivy-1.10.1
pylint:
type: test
script:
- pipenv install --skip-lock pylint
- pipenv run pylint main
- pipenv run pylint settings
- pipenv run pylint modules
......@@ -19,5 +21,5 @@ pylint:
pytest:
type: test
script:
- pipenv run pytest tests
- pipenv run pytest --cov=modules
- pipenv install --skip-lock pytest pytest-cov
- pipenv run pytest tests --cov=modules
......@@ -54,7 +54,8 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=pointless-string-statement,
disable=unused-import,
pointless-string-statement,
useless-super-delegation,
parameter-unpacking,
unpacking-in-except,
......
......@@ -9,8 +9,8 @@ pytest = "==3.6.0"
pytest-cov = "==2.5.1"
[packages]
cython = "==0.23"
kivy = "==1.9.1"
cython = "==0.28"
requests = "==2.19.1"
[requires]
python_version = "3.5"
This diff is collapsed.
v0.0.1
## June 7 2018
- Sign Up feature added.
## June 11 2018
- Adding Dashboard feature
- Adding blog, cli, communication, encryption, how_to_use, vcs and way_ahead modules for courseware
- Adding application, profile and theme modules for settings
- Adding Dashboard feature (Shashank Kumar)
- Adding blog, cli, communication, encryption, how_to_use, vcs and way_ahead modules for courseware (Shashank Kumar)
- Adding application, profile and theme modules for settings (Shashank Kumar)
## June 7 2018
- Sign Up feature added. (Shashank Kumar)
## June 3 2018
- Reporting coverage while running Gitlab CI.
- Reporting coverage while running Gitlab CI. (Shashank Kumar)
## June 1 2018
- Initial app setup using Kivy.
- Integrate pylint, pytest and support for Gitlab CI.
- Initial app setup using Kivy. (Shashank Kumar)
- Integrate pylint, pytest and support for Gitlab CI. (Shashank Kumar)
......@@ -52,7 +52,11 @@ Step 4: Install application dependencies (this might take a while, grab a cup of
`$ pipenv install`
Step 5: Run New Contributor Wizard
Step 5: Install Kivy
`$ pipenv install --skip-lock git+http://github.com/kivy/kivy.git#egg=kivy-1.10.1`
Step 6: Run New Contributor Wizard
`$ pipenv run python main.py`
......
......@@ -3,25 +3,27 @@ Root Kivy Application
'''
from kivy.app import App
from kivy.config import Config
from kivy.uix.screenmanager import ScreenManager
from settings import initializing_database
from modules.signup import signup
from modules.dashboard import dashboard
from settings import initializing_database, installing_kivy_garden_package
class NewContributorWizard(App):
'''
Declaration of Root Kivy App which contains Root Widget
'''
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen_manager_obj = ScreenManager()
self.screen_manager_obj.add_widget(signup.SignUp(name='signup'))
self.screen_manager_obj.add_widget(dashboard.Dashboard(name='dashboard'))
def build(self):
return self.screen_manager_obj
'''
Overridding build method of App class to load custom kv file
'''
self.load_kv('./ui/main.kv')
def switch_screen_to_dashboard(self):
'''
This method helps clear the widget and switch directly to the Dashboard
'''
self.root.clear_widgets()
self.root.add_widget(Dashboard())
if __name__ == '__main__':
......@@ -29,15 +31,16 @@ if __name__ == '__main__':
Setting up things
'''
initializing_database()
installing_kivy_garden_package('navigationdrawer')
'''
Setting window width to 720px and height to 480px
'''
Config.set('graphics', 'width', '720')
Config.set('graphics', 'height', '480')
Config.set('graphics', 'resizable', False)
# Importing modules
from modules.dashboard.dashboard import Dashboard
from modules.signup.signup import SignUp
'''
Running Kivy application and building root Widget
'''
# Fixing touch issue with some platforms
Config.set('input', 'mouse', 'mouse')
Config.set('graphics', 'minimum_width', 720)
Config.set('graphics', 'minimum_height', 480)
# Running Kivy application and building root Widget
NewContributorWizard().run()
'''
Dashboard module includes classes to showcase Dashboard with different courseware and settings
'''
from copy import copy as cp
import logging
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
try:
from libs.garden.navigationdrawer import NavigationDrawer
except ImportError:
logging.info('Dashboard: Install navigationdrawer from garden')
from modules.blog.blog import Blog
from modules.cli.cli import CLI
......@@ -26,50 +30,4 @@ class Dashboard(BoxLayout, Screen):
'''
Dashboard class to integrate courseware and settings
'''
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.all_menu_screens = {
'application_settings': ApplicationSettings(),
'blog': Blog(),
'cli': CLI(),
'communication': Communication(),
'encryption': Encryption(),
'how_to_use': HowToUse(),
'profile_settings': ProfileSettings(),
'theme_settings': ThemeSettings(),
'vcs': VCS(),
'way_ahead': WayAhead(),
}
self.all_menu_items = list(self.all_menu_screens.keys())
self.enable_menu('how_to_use')
def on_touch_down(self, touch):
'''
on_touch_down is triggered when user clicks the application anywhere
overiding this function here to perform actions on selection of menu items
'''
for menu_item in self.all_menu_items:
if self.ids[menu_item+'_box'].collide_point(*touch.pos):
self.enable_menu(menu_item)
def enable_menu(self, menu_item_to_enable):
'''
enable_menu function focuses on concerned menu items or settings which is clicked and
removes focus from all other menu items and settings
'''
menu_item_to_enable_widget = self.ids[menu_item_to_enable+'_box']
menu_item_to_enable_color = menu_item_to_enable_widget.canvas.before.children[0].rgba
if menu_item_to_enable_color != [1, 1, 1, 1] or 'settings' in menu_item_to_enable:
self.ids['module_screen'].add_widget(self.all_menu_screens[menu_item_to_enable])
if 'settings' not in menu_item_to_enable:
self.ids[menu_item_to_enable+'_box'].canvas.before.children[0].rgba = [1, 1, 1, 1]
self.ids[menu_item_to_enable+'_label'].color = (0, 0, 0, 1)
all_menu_items_copy = cp(self.all_menu_items)
all_menu_items_copy.remove(menu_item_to_enable)
for menu_item in all_menu_items_copy:
if 'settings' not in menu_item:
self.ids[menu_item+'_box'].canvas.before.children[0].rgba = [0, 0, 0, 1]
self.ids[menu_item+'_label'].color = (1, 1, 1, 1)
self.ids['module_screen'].remove_widget(self.all_menu_screens[menu_item])
pass
......@@ -3,6 +3,7 @@ Class for SignUp Screen
'''
import logging
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.clock import Clock
......@@ -25,34 +26,26 @@ class SignUp(BoxLayout, Screen):
'''
Declaration of SignUp Screen Class
'''
def __init__(self, **kwargs):
'''
Creating instance of vaidation class
Creating instance of updateBD class
'''
super().__init__(**kwargs)
def prompt_error_message(self, label, error_text):
'''
Displays error message on the UI on the respective label widget
'''
original_text = self.ids[label].text
self.ids[label].text = error_text
self.ids[label].color = (255, 0, 0, 1)
self.ids[label].color = [1, 0, 0, 1]
def replace_label(*args):
'''
Replacing original text in label
delay time is defined by args[0]
'''
self.ids[label].text = original_text
self.ids[label].color = [1, 1, 1, 1]
logging.info(
'\'%s\' changed to \'%s\' after %s seconds',
error_text,
original_text,
args[0]
)
self.ids[label].text = original_text
self.ids[label].color = (255, 255, 255, 1)
Clock.schedule_once(replace_label, 2)
def validate(self):
......@@ -105,11 +98,12 @@ class SignUp(BoxLayout, Screen):
return email_validation and pass_validation and full_name_validation
def sign_up(self):
def sign_up(self, *args):
'''
Signing Up user's account in case of successful validation
Prompting error message to the user otherwise
'''
app_object = args[0]
if self.validate():
user_email = self.ids['user_email'].text
user_pass = self.ids['first_pass'].text
......@@ -125,7 +119,7 @@ class SignUp(BoxLayout, Screen):
}
try:
sign_up_user(**user_info)
self.manager.current = 'dashboard'
app_object.switch_screen_to_dashboard()
except SignUpError as error:
self.prompt_error_message(
'email_label',
......
......@@ -2,8 +2,13 @@
Initializing application dependencies
- Sqlite3 database
'''
import os
import sqlite3
import logging
from zipfile import ZipFile
from io import BytesIO
import requests
DATABASE_FILE = 'new_contributor_wizard.db'
USER_INFOMATION_TABLE = 'USERS'
......@@ -29,3 +34,44 @@ def initializing_database():
return connection
except sqlite3.OperationalError:
return connection
def installing_kivy_garden_package(package_name):
'''
Installing garden package and moving it to 'libs/garden/'
'''
logging.basicConfig(level=logging.INFO)
if not package_name.startswith('garden.'):
package_name = 'garden.' + package_name
url = 'https://github.com/kivy-garden/{}/archive/master.zip'.format(
package_name
)
compact_package_name = package_name.split('garden.')[1]
root_directory = os.getcwd()
existing_garden_packages = os.listdir(root_directory + '/libs/garden')
if compact_package_name in existing_garden_packages:
logging.info('Garden: %s exists', compact_package_name)
return
logging.info('Garden: Downloading %s ...', url)
response = requests.get(url)
if response.status_code != 200:
logging.info('''Garden: Unable to find the garden package.
(error=%s)''', response.status_code)
return
data = b''
for buf in response.iter_content(1024):
data += buf
logging.info('Garden: Download done (%s downloaded)', package_name)
ZipFile(BytesIO(data)).extractall()
for existing_files_folders in os.listdir(root_directory):
if 'garden.' in existing_files_folders:
new_name = root_directory + '/libs/garden/' + compact_package_name
os.rename(existing_files_folders, new_name)
success_log = compact_package_name + ' relocated to ' + new_name
logging.info('Garden: %s', success_log)
break
<Dashboard>:
BoxLayout:
size_hint: 0.3, 1
orientation: 'vertical'
BoxLayout:
size_hint: 1, 0.1
BoxLayout:
size_hint: 1, 0.8
<Dashboard>
NavigationDrawer
id: navid
anim_type: 'slide_above_anim'
BoxLayout
orientation: 'vertical'
id: dashboard_menu
BoxLayout:
BoxLayout
size_hint: 1, 0.142
padding: 0, 0, 10, 0
MenuButton
id: how_to_use_box
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
pos: self.pos
size: self.size
Label:
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
text: 'How To Use'
on_press: nav_screen.current = 'how_to_use_screen'
MenuLabel
id: how_to_use_label
BoxLayout:
size_hint: 1, 0.142
padding: 0, 0, 10, 0
text: 'How To Use'
MenuButton
id: communication_box
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
pos: self.pos
size: self.size
Label:
text: 'Communication'
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
on_press: nav_screen.current = 'communication_screen'
MenuLabel
id: communication_label
BoxLayout:
size_hint: 1, 0.142
padding: 0, 0, 10, 0
text: 'Communication'
MenuButton
id: cli_box
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
pos: self.pos
size: self.size
Label:
text: 'CLI'
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
on_press: nav_screen.current = 'cli_screen'
MenuLabel
id: cli_label
BoxLayout:
size_hint: 1, 0.142
padding: 0, 0, 10, 0
text: 'CLI'
MenuButton
id: blog_box
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
pos: self.pos
size: self.size
Label:
text: 'Blog'
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
on_press: nav_screen.current = 'blog_screen'
MenuLabel
id: blog_label
BoxLayout:
size_hint: 1, 0.142
padding: 0, 0, 10, 0
text: 'Blog'
MenuButton
id: vcs_box
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
pos: self.pos
size: self.size
Label:
text: 'Version Control'
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
on_press: nav_screen.current = 'vcs_screen'
MenuLabel
id: vcs_label
BoxLayout:
size_hint: 1, 0.142
padding: 0, 0, 10, 0
text: 'VCS'
MenuButton
id: encryption_box
on_press: nav_screen.current = 'encryption_screen'
MenuLabel
id: encryption_label
text: 'Encryption'
MenuButton
id: way_ahead_box
on_press: nav_screen.current = 'way_ahead_screen'
MenuLabel
id: way_ahead_label
text: 'Way Ahead'
MenuButton
BoxLayout
orientation: 'vertical'
BoxLayout
size_hint: 1, 0.1
padding: 0, 0, dp(50), 0
Button
size_hint_x: None
width: self.height
border: 0, 0, 0, 0
background_normal: 'ui/assets/images/ham.png'
on_press: navid.toggle_state()
Label
size_hint: 0.9, 1
text: 'Welcome'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: dp(25)
ScreenManager
id: nav_screen
size_hint: 1, 0.9
Screen
name: 'welcome_screen'
BoxLayout
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
Color
rgba: 1, 1, 1, 1
Rectangle
pos: self.pos
size: self.size
Label:
text: 'Encryption'
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
Label
text: 'Please select a module from the left to begin'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
id: encryption_label
BoxLayout:
font_size: dp(30)
color: 0, 0, 0, 1
Screen
name: 'blog_screen'
Blog
Screen
name: 'cli_screen'
CLI
Screen
name: 'communication_screen'
Communication
Screen
name: 'encryption_screen'
Encryption
Screen
name: 'how_to_use_screen'
HowToUse
Screen
name: 'vcs_screen'
VCS
Screen
name: 'way_ahead_screen'
WayAhead
Screen
name: 'application_settings_screen'
ApplicationSettings
Screen
name: 'profile_settings_screen'
ProfileSettings
Screen
name: 'theme_settings_screen'
ThemeSettings
<MenuButton@ButtonBehavior+BoxLayout>
size_hint: 1, 0.142
padding: 0, 0, 10, 0
id: way_ahead_box
on_release: app.root.children[0].ids['navid'].toggle_state()
canvas.before:
Color:
Color
rgba: 0, 0, 0, 1
Rectangle:
Rectangle
pos: self.pos
size: self.size
Label:
text: 'Way Ahead'
<MenuLabel@Label>
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
id: way_ahead_label
BoxLayout
size_hint: 1, 0.05
padding: 0, 0, 10, 0
BoxLayout:
size_hint: 1, 0.15
BoxLayout:
size_hint: 0.33, 0.8
id: profile_settings_box
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
Image:
source: 'ui/assets/images/avatar.png'
BoxLayout:
size_hint: 0.33, 0.8
id: theme_settings_box
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
Image:
source: 'ui/assets/images/paint.png'
BoxLayout:
size_hint: 0.33, 0.8
id: application_settings_box
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
Image:
source: 'ui/assets/images/settings.png'
BoxLayout:
size_hint: 0.7, 1
canvas.before:
Color:
rgba: 0.114, 0.306, 0.537, 1
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
id: module_screen
font_size: dp(20)
<Dashboard>:
BoxLayout:
size_hint: 0.3, 1
orientation: 'vertical'
BoxLayout:
size_hint: 1, 0.1
BoxLayout:
size_hint: 1, 0.8
orientation: 'vertical'
id: dashboard_menu
BoxLayout:
size_hint: 1, 0.142
padding: 0, 0, 10, 0
id: how_to_use_box
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
pos: self.pos
size: self.size
Label:
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
text: 'How To Use'
id: how_to_use_label
BoxLayout:
size_hint: 1, 0.142
padding: 0, 0, 10, 0
id: communication_box
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
pos: self.pos
size: self.size
Label:
text: 'Communication'
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
id: communication_label
BoxLayout:
size_hint: 1, 0.142
padding: 0, 0, 10, 0
id: cli_box
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
pos: self.pos
size: self.size
Label:
text: 'CLI'
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
id: cli_label
BoxLayout:
size_hint: 1, 0.142
padding: 0, 0, 10, 0
id: blog_box
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
pos: self.pos
size: self.size
Label:
text: 'Blog'
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
id: blog_label
BoxLayout:
size_hint: 1, 0.142
padding: 0, 0, 10, 0
id: vcs_box
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
pos: self.pos
size: self.size
Label:
text: 'Version Control'
text_size: self.size
size: self.texture_size
valign: 'middle'
halign: 'right'
font_name: 'ui/assets/fonts/VarelaRound-Regular.ttf'
font_size: 20
id: vcs_label
BoxLayout:
size_hint: 1, 0.142
padding: 0, 0, 10, 0