Beispiel #1
0
 def add(self, environment):
     item = {
         'ref': GeneralHelper.prepare_string(environment.ref_name),
         'name': GeneralHelper.prepare_string(environment.name),
         'path': environment.path,
         'db_user': GeneralHelper.prepare_string(environment.db_user),
         'db_password': GeneralHelper.prepare_string(environment.db_pw)
     }
     self.items.append(item)
     environment.init_env_project_file()
     self.init_directus_env(environment)
     self.write()
Beispiel #2
0
 def load_projects(self):
     self.projects = []
     for line in open("data/envs/{ref_name}.txt".format(
             ref_name=self.ref_name)).readlines():
         if line:
             try:
                 item = {}
                 data = line.split('\t')
                 item['ref'] = data[0]
                 item['database'] = GeneralHelper.prepare_string(data[1])
                 item['name'] = GeneralHelper.prepare_string(data[2])
                 self.projects.append(item)
             except KeyError:
                 pass
Beispiel #3
0
 def create_db_migration(self):
     raw_tables = self.get_db_tables()
     tables = list(map(lambda d: d[0], raw_tables))
     clean_tables = self.remove_blacklist(tables)
     file_name = "{pj_ref}-{db}-{timestamp}".format(
         pj_ref=self.name,
         db=self.database,
         timestamp=GeneralHelper.prepare_string(str(datetime.now())))
     os.system(
         'mysqldump -u {username} --password="******" {database} {tables} '
         '> data/migrations/{filename}.sql'.format(
             username=self.username,
             password=self.password,
             database=self.database,
             tables=" ".join(clean_tables),
             filename=file_name))
Beispiel #4
0
 def __init__(self, ref, name=None, database=None):
     self.ref_name = GeneralHelper.prepare_string(ref)
     if name:
         self.name = GeneralHelper.prepare_name(name)
     self.name = name
     self.database = database