def update_yarn_depenencies(self, version): packages_path = os.path.join(settings.APP_ROOT, 'package.json') yarn_config_path = os.path.join(settings.APP_ROOT, '.yarnrc') if self.overwite_existing_file( yarn_config_path, "A .yarnrc file already exists. Would you like to overwrite it with the latest? If you have not manually modified this file since creating this project, the answer is probably 'yes'" ) == True: with open(yarn_config_path, 'w') as f: content = '--install.modules-folder "./media/packages"\n--add.modules-folder "./media/packages"' f.write(content) if self.overwite_existing_file( packages_path, "A package.json file already exists. Would you like to overwrite it with the latest? If you have not manually modified this file since creating this project, the answer is probably 'yes'" ) == True: url = "https://raw.githubusercontent.com/archesproject/arches/stable/{0}/package.json".format( version) response = urllib.urlopen(url) data = json.loads(response.read()) with open(packages_path, 'w') as f: json.dump(data, f, indent=4) if utils.get_yn_input( "Would you like to update your javascript packages using yarn? Yarn v1.5.1 or greater is required" ) == True: try: os.chdir(settings.APP_ROOT) subprocess.call("yarn install", shell=True) except Exception as e: print e
def overwite_existing_file(self, path, message): write_file = False if os.path.exists(path) == True: if not utils.get_yn_input(message): return write_file else: write_file = True else: write_file = True return write_file
def handle(self, *args, **options): if options["force"] is False: proceed = get_yn_input( msg= "Are you sure you want to destroy and rebuild your database?", default="N") if not proceed: exit() self.setup_db()
def remove_resources(self, load_id='', force=False): """ Runs the resource_remover command found in data_management.resources """ # resource_remover.delete_resources(load_id) if not force: if not utils.get_yn_input("all resources will be removed. continue?"): return resource_remover.clear_resources() return
def remove_resources(self, load_id='', force=False): """ Runs the resource_remover command found in data_management.resources """ # resource_remover.delete_resources(load_id) if not force: if not utils.get_yn_input( "all resources will be removed. continue?"): return resource_remover.clear_resources() return
def remove_resources(self, load_id='', graphid=None, force=False): """ Runs the resource_remover command found in data_management.resources """ # resource_remover.delete_resources(load_id) if not force: if graphid == None: if not utils.get_yn_input( "all resources will be removed. continue?"): return else: if not utils.get_yn_input( "All resources associated with the '%s' Resource Model will be removed. continue?" % Graph.objects.get(graphid=graphid).name): return if graphid == None: resource_remover.clear_resources() else: graph = Graph.objects.get(graphid=graphid) graph.delete_instances(verbose=True) return