Commit 48aca0a0 authored by Shashank Kumar's avatar Shashank Kumar

resolves FileNotFoundError on missing libs/garden/

parent d732d9af
...@@ -12,6 +12,7 @@ import requests ...@@ -12,6 +12,7 @@ import requests
DATABASE_FILE = 'new_contributor_wizard.db' DATABASE_FILE = 'new_contributor_wizard.db'
USER_INFOMATION_TABLE = 'USERS' USER_INFOMATION_TABLE = 'USERS'
LIBRARY_GARDEN_PATH = 'libs/garden/'
def get_db_connection(): def get_db_connection():
...@@ -38,7 +39,7 @@ def get_db_connection(): ...@@ -38,7 +39,7 @@ def get_db_connection():
def installing_kivy_garden_package(package_name): def installing_kivy_garden_package(package_name):
''' '''
Installing garden package and moving it to 'libs/garden/' Installing garden package and moving it to LIBRARY_GARDEN_PATH
''' '''
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
if not package_name.startswith('garden.'): if not package_name.startswith('garden.'):
...@@ -49,7 +50,15 @@ def installing_kivy_garden_package(package_name): ...@@ -49,7 +50,15 @@ def installing_kivy_garden_package(package_name):
compact_package_name = package_name.split('garden.')[1] compact_package_name = package_name.split('garden.')[1]
root_directory = os.getcwd() root_directory = os.getcwd()
existing_garden_packages = os.listdir(root_directory + '/libs/garden') try:
existing_garden_packages = os.listdir(
root_directory + '/' + LIBRARY_GARDEN_PATH
)
except FileNotFoundError:
os.makedirs('libs/garden')
existing_garden_packages = os.listdir(
root_directory + '/' + LIBRARY_GARDEN_PATH
)
if compact_package_name in existing_garden_packages: if compact_package_name in existing_garden_packages:
logging.info('Garden: %s exists', compact_package_name) logging.info('Garden: %s exists', compact_package_name)
return return
...@@ -70,7 +79,7 @@ def installing_kivy_garden_package(package_name): ...@@ -70,7 +79,7 @@ def installing_kivy_garden_package(package_name):
for existing_files_folders in os.listdir(root_directory): for existing_files_folders in os.listdir(root_directory):
if 'garden.' in existing_files_folders: if 'garden.' in existing_files_folders:
new_name = root_directory + '/libs/garden/' + compact_package_name new_name = root_directory + '/' + LIBRARY_GARDEN_PATH + compact_package_name
os.rename(existing_files_folders, new_name) os.rename(existing_files_folders, new_name)
success_log = compact_package_name + ' relocated to ' + new_name success_log = compact_package_name + ' relocated to ' + new_name
logging.info('Garden: %s', success_log) logging.info('Garden: %s', success_log)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment