def execute( context: cli.CommandContext, project_name: str, directory: str, title: str = '', summary: str = '', author: str = '', forget: bool = False, no_naming_scheme: bool = False, library_folder: str = None, assets_folder: str = None ): """ :return: """ response = context.response response.consume(create_actions.create_project_directories( project_name, directory, assets_folder=assets_folder, library_folder=library_folder )) if response.failed: return response definition = create_actions.create_definition( name=project_name, title=title, summary=summary, author=author, no_naming_scheme=no_naming_scheme, library_folder=library_folder, assets_folder=assets_folder ) source_directory = response.data['source_directory'] response.consume(create_actions.write_project_data( source_directory, definition )) response.consume(create_actions.write_project_data( source_directory, definition )) if response.failed: return response if context.remote_connection.active: opened = remote_project_opener.sync_open(context, source_directory) else: opened = project_opener.open_project( source_directory, forget=forget ) return response.consume(opened)
def execute( context: cli.CommandContext, path: str = None, last_opened_project: bool = False, a_recent_project: bool = False, show_in_browser: bool = False, list_available: bool = False, forget: bool = False, results_path: str = None ) -> Response: """ :return: """ response = context.response path = path.strip('"') if path else None if list_available: actions.echo_known_projects(response) return response if last_opened_project: path = actions.fetch_last(response) if not path: return response elif a_recent_project: path = actions.fetch_recent(response) if not path: return response elif not path or not path.strip(): actions.echo_known_projects(response) return response else: p = actions.fetch_location(response, path) path = p if p else path if context.remote_connection.active: response.consume(remote_opener.sync_open( context=context, path=path, forget=forget )) else: response.consume(opener.open_project( path=path, forget=forget, results_path=results_path )) if not response.failed and show_in_browser: cli.open_in_browser(cauldron.project.internal_project) return response
def execute(context: cli.CommandContext, project_name: str, directory: str, title: str = '', summary: str = '', author: str = '', forget: bool = False, no_naming_scheme: bool = False, library_folder: str = None, assets_folder: str = None): """ :return: """ response = context.response response.consume( create_actions.create_project_directories( project_name, directory, assets_folder=assets_folder, library_folder=library_folder)) if response.failed: return response definition = create_actions.create_definition( name=project_name, title=title, summary=summary, author=author, no_naming_scheme=no_naming_scheme, library_folder=library_folder, assets_folder=assets_folder) source_directory = response.data['source_directory'] response.consume( create_actions.write_project_data(source_directory, definition)) response.consume( create_actions.write_project_data(source_directory, definition)) if response.failed: return response if context.remote_connection.active: opened = remote_project_opener.sync_open(context, source_directory) else: opened = project_opener.open_project(source_directory, forget=forget) return response.consume(opened)
def sync_open_project(): """ """ r = Response() args = arguments.from_request() definition = args.get('definition') source_directory = args.get('source_directory') if None in [definition, source_directory]: return r.fail( code='INVALID_ARGS', message='Invalid arguments. Unable to open project' ).response.flask_serialize() # Remove any shared library folders from the library list. These will be # stored using the single shared library folder instead definition['library_folders'] = [ lf for lf in definition.get('library_folders', ['libs']) if lf and not lf.startswith('..') ] definition['library_folders'] += ['../__cauldron_shared_libs'] container_folder = tempfile.mkdtemp(prefix='cd-remote-project-') os.makedirs(os.path.join(container_folder, '__cauldron_shared_libs')) os.makedirs(os.path.join(container_folder, '__cauldron_downloads')) project_folder = os.path.join(container_folder, definition['name']) os.makedirs(project_folder) definition_path = os.path.join(project_folder, 'cauldron.json') writer.write_json_file(definition_path, definition) sync_status.update({}, time=-1, project=None) open_response = project_opener.open_project(project_folder, forget=True) open_response.join() project = cd.project.get_internal_project() project.remote_source_directory = source_directory sync_status.update({}, time=-1, project=project) return r.consume(open_response).update( source_directory=project.source_directory, project=project.kernel_serialize() ).notify( kind='OPENED', code='PROJECT_OPENED', message='Project opened' ).response.flask_serialize()
def execute(context: cli.CommandContext, path: str = None, last_opened_project: bool = False, a_recent_project: bool = False, show_in_browser: bool = False, list_available: bool = False, forget: bool = False, results_path: str = None) -> Response: """ :return: """ response = context.response path = path.strip('"') if path else None if list_available: actions.echo_known_projects(response) return response if last_opened_project: path = actions.fetch_last(response) if not path: return response elif a_recent_project: path = actions.fetch_recent(response) if not path: return response elif not path or not path.strip(): actions.echo_known_projects(response) return response else: p = actions.fetch_location(response, path) path = p if p else path if context.remote_connection.active: response.consume( remote_opener.sync_open(context=context, path=path, forget=forget)) else: response.consume( opener.open_project(path=path, forget=forget, results_path=results_path)) if not response.failed and show_in_browser: cli.open_in_browser(cauldron.project.internal_project) return response
def sync_open_project(): """ """ r = Response() args = arguments.from_request() definition = args.get('definition') source_directory = args.get('source_directory') if None in [definition, source_directory]: return r.fail(code='INVALID_ARGS', message='Invalid arguments. Unable to open project' ).response.flask_serialize() # Remove any shared library folders from the library list. These will be # stored using the single shared library folder instead definition['library_folders'] = [ lf for lf in definition.get('library_folders', ['libs']) if lf and not lf.startswith('..') ] definition['library_folders'] += ['../__cauldron_shared_libs'] container_folder = tempfile.mkdtemp(prefix='cd-remote-project-') os.makedirs(os.path.join(container_folder, '__cauldron_shared_libs')) os.makedirs(os.path.join(container_folder, '__cauldron_downloads')) project_folder = os.path.join(container_folder, definition['name']) os.makedirs(project_folder) definition_path = os.path.join(project_folder, 'cauldron.json') writer.write_json_file(definition_path, definition) sync_status.update({}, time=-1, project=None) open_response = project_opener.open_project(project_folder, forget=True) open_response.join() project = cd.project.get_internal_project() project.remote_source_directory = source_directory sync_status.update({}, time=-1, project=project) return r.consume(open_response).update( source_directory=project.source_directory, project=project.kernel_serialize()).notify( kind='SUCCESS', code='PROJECT_OPENED', message='Project opened').response.flask_serialize()
def test_not_update(self, *args): """ should fail when project does not load """ response = opener.open_project(INVALID_PATH, forget=False) self.assertTrue(response.failed)
def test_not_exists_open(self, *args): """ should fail when the project does not exist """ response = opener.open_project(INVALID_PATH, forget=True) self.assertTrue(response.failed)
def test_not_loadable_open(self, project_exists): """ should fail when project does not load """ response = opener.open_project(INVALID_PATH, forget=True) self.assertTrue(response.failed)