so now we can load modules dynamically. Also, the tutorials for python seem insane. Why was this simple answer not the first to pop. Ugh.
This commit is contained in:
@@ -1,11 +0,0 @@
|
|||||||
import os
|
|
||||||
from libs.utils.common import *
|
|
||||||
|
|
||||||
|
|
||||||
# Get the application's path (wherever weirdAAL.py is located will be the dirpath )
|
|
||||||
dirpath = os.getcwd()
|
|
||||||
# The actual location of this file on the filesystem is the "foldername"
|
|
||||||
foldername = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
|
|
||||||
all_files = list_all_files(foldername)
|
|
||||||
__all__ = all_files
|
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ def list_all_files(directory):
|
|||||||
|
|
||||||
for file in list_of_files:
|
for file in list_of_files:
|
||||||
filename_and_ext = os.path.splitext(file)
|
filename_and_ext = os.path.splitext(file)
|
||||||
if filename_and_ext[1] == ".py":
|
if (filename_and_ext[1] == ".py") and not (filename_and_ext[0].startswith("__")):
|
||||||
array.append(filename_and_ext[0])
|
array.append(filename_and_ext[0])
|
||||||
return array
|
return array
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
from libs.utils.common import *
|
from libs.utils.common import *
|
||||||
|
|
||||||
|
|
||||||
# Get the application's path (wherever weirdAAL.py is located will be the dirpath )
|
# Get the application's path (wherever weirdAAL.py is located will be the dirpath )
|
||||||
dirpath = os.getcwd()
|
dirpath = os.getcwd()
|
||||||
# The actual location of this file on the filesystem is the "foldername"
|
# The actual location of this file on the filesystem is the "foldername"
|
||||||
foldername = os.path.dirname(os.path.realpath(__file__))
|
foldername = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
all_files = list_all_files(foldername)
|
all_modules = list_all_files(foldername)
|
||||||
|
|
||||||
__all__ = all_files
|
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ import os
|
|||||||
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
|
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
from modules import *
|
from modules import *
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append("modules")
|
||||||
|
for module in all_modules:
|
||||||
|
exec("from %s import *"%module)
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-s", "--step", help="list the step you would like to run",
|
parser.add_argument("-s", "--step", help="list the step you would like to run",
|
||||||
|
|||||||
Reference in New Issue
Block a user