def measure_caller(calller_id): calller_id = str(calller_id)[:20].lower() event = { "category": "Caller", "action": "Misc", "label": calller_id } if calller_id in (["atom", "vim"] + ProjectGenerator.get_supported_ides()): event['action'] = "IDE" on_event(**event)
def init(self, board, framework, project_dir): assert project_dir state = AppRPC.load_state() if not isdir(project_dir): os.makedirs(project_dir) args = ["init", "--board", board] if framework: args.extend(["--project-option", "framework = %s" % framework]) if (state['storage']['coreCaller'] and state['storage']['coreCaller'] in ProjectGenerator.get_supported_ides()): args.extend(["--ide", state['storage']['coreCaller']]) d = PIOCoreRPC.call(args, options={"cwd": project_dir}) d.addCallback(self._generate_project_main, project_dir, framework) return d
async def init(self, board, framework, project_dir): assert project_dir state = AppRPC.load_state() if not os.path.isdir(project_dir): os.makedirs(project_dir) args = ["init", "--board", board] if framework: args.extend(["--project-option", "framework = %s" % framework]) if (state["storage"]["coreCaller"] and state["storage"]["coreCaller"] in ProjectGenerator.get_supported_ides()): args.extend(["--ide", state["storage"]["coreCaller"]]) await PIOCoreRPC.call(args, options={ "cwd": project_dir, "force_subprocess": True }) return self._generate_project_main(project_dir, framework)
async def import_arduino(self, board, use_arduino_libs, arduino_project_dir): board = str(board) # don't import PIO Project if is_platformio_project(arduino_project_dir): return arduino_project_dir is_arduino_project = any([ os.path.isfile( os.path.join( arduino_project_dir, "%s.%s" % (os.path.basename(arduino_project_dir), ext), )) for ext in ("ino", "pde") ]) if not is_arduino_project: raise jsonrpc.exceptions.JSONRPCDispatchException( code=4000, message="Not an Arduino project: %s" % arduino_project_dir) state = AppRPC.load_state() project_dir = os.path.join(state["storage"]["projectsDir"], time.strftime("%y%m%d-%H%M%S-") + board) if not os.path.isdir(project_dir): os.makedirs(project_dir) args = ["init", "--board", board] args.extend(["--project-option", "framework = arduino"]) if use_arduino_libs: args.extend([ "--project-option", "lib_extra_dirs = ~/Documents/Arduino/libraries" ]) if (state["storage"]["coreCaller"] and state["storage"]["coreCaller"] in ProjectGenerator.get_supported_ides()): args.extend(["--ide", state["storage"]["coreCaller"]]) await PIOCoreRPC.call(args, options={ "cwd": project_dir, "force_subprocess": True }) with fs.cd(project_dir): config = ProjectConfig() src_dir = config.get_optional_dir("src") if os.path.isdir(src_dir): fs.rmtree(src_dir) shutil.copytree(arduino_project_dir, src_dir, symlinks=True) return project_dir
def import_pio(project_dir): if not project_dir or not is_platformio_project(project_dir): raise jsonrpc.exceptions.JSONRPCDispatchException( code=4001, message="Not an PlatformIO project: %s" % project_dir) new_project_dir = join( AppRPC.load_state()['storage']['projectsDir'], time.strftime("%y%m%d-%H%M%S-") + basename(project_dir)) shutil.copytree(project_dir, new_project_dir) state = AppRPC.load_state() args = ["init"] if (state['storage']['coreCaller'] and state['storage']['coreCaller'] in ProjectGenerator.get_supported_ides()): args.extend(["--ide", state['storage']['coreCaller']]) d = PIOCoreRPC.call(args, options={"cwd": new_project_dir}) d.addCallback(lambda _: new_project_dir) return d
def import_arduino(self, board, use_arduino_libs, arduino_project_dir): board = str(board) if arduino_project_dir and PY2: arduino_project_dir = arduino_project_dir.encode( get_filesystem_encoding()) # don't import PIO Project if is_platformio_project(arduino_project_dir): return arduino_project_dir is_arduino_project = any([ os.path.isfile( os.path.join( arduino_project_dir, "%s.%s" % (os.path.basename(arduino_project_dir), ext), )) for ext in ("ino", "pde") ]) if not is_arduino_project: raise jsonrpc.exceptions.JSONRPCDispatchException( code=4000, message="Not an Arduino project: %s" % arduino_project_dir) state = AppRPC.load_state() project_dir = os.path.join(state["storage"]["projectsDir"], time.strftime("%y%m%d-%H%M%S-") + board) if not os.path.isdir(project_dir): os.makedirs(project_dir) args = ["init", "--board", board] args.extend(["--project-option", "framework = arduino"]) if use_arduino_libs: args.extend([ "--project-option", "lib_extra_dirs = ~/Documents/Arduino/libraries" ]) if (state["storage"]["coreCaller"] and state["storage"]["coreCaller"] in ProjectGenerator.get_supported_ides()): args.extend(["--ide", state["storage"]["coreCaller"]]) d = PIOCoreRPC.call(args, options={ "cwd": project_dir, "force_subprocess": True }) d.addCallback(self._finalize_arduino_import, project_dir, arduino_project_dir) return d
async def import_pio(project_dir): if not project_dir or not is_platformio_project(project_dir): raise JSONRPC20DispatchException( code=4001, message="Not an PlatformIO project: %s" % project_dir) new_project_dir = os.path.join( AppRPC.load_state()["storage"]["projectsDir"], time.strftime("%y%m%d-%H%M%S-") + os.path.basename(project_dir), ) shutil.copytree(project_dir, new_project_dir, symlinks=True) state = AppRPC.load_state() args = ["init"] if (state["storage"]["coreCaller"] and state["storage"]["coreCaller"] in ProjectGenerator.get_supported_ides()): args.extend(["--ide", state["storage"]["coreCaller"]]) await PIOCoreRPC.call(args, options={ "cwd": new_project_dir, "force_subprocess": True }) return new_project_dir
short_help="Initialize PlatformIO project or update existing") @click.option("--project-dir", "-d", default=getcwd, type=click.Path(exists=True, file_okay=False, dir_okay=True, writable=True, resolve_path=True)) @click.option("-b", "--board", multiple=True, metavar="ID", callback=validate_boards) @click.option("--ide", type=click.Choice(ProjectGenerator.get_supported_ides())) @click.option("-O", "--project-option", multiple=True) @click.option("--env-prefix", default="") @click.option("-s", "--silent", is_flag=True) @click.pass_context def cli( ctx, # pylint: disable=R0913 project_dir, board, ide, project_option, env_prefix, silent): if not silent: if project_dir == getcwd():
def measure_caller(calller_id): calller_id = str(calller_id)[:20].lower() event = {"category": "Caller", "action": "Misc", "label": calller_id} if calller_id in (["atom", "vim"] + ProjectGenerator.get_supported_ides()): event['action'] = "IDE" on_event(**event)
assert not unknown_boards return value except AssertionError: raise click.BadParameter( "%s. Please search for the board types using " "`platformio boards` command" % ", ".join(unknown_boards)) @click.command("init", short_help="Initialize new PlatformIO based project") @click.option("--project-dir", "-d", default=getcwd, type=click.Path(exists=True, file_okay=False, dir_okay=True, writable=True, resolve_path=True)) @click.option("--board", "-b", multiple=True, metavar="TYPE", callback=validate_boards) @click.option("--ide", type=click.Choice(ProjectGenerator.get_supported_ides())) @click.option("--enable-auto-uploading", is_flag=True) @click.option("--env-prefix", default="") @click.pass_context def cli(ctx, project_dir, board, ide, # pylint: disable=R0913 enable_auto_uploading, env_prefix): if project_dir == getcwd(): click.secho("\nThe current working directory", fg="yellow", nl=False) click.secho(" %s " % project_dir, fg="cyan", nl=False) click.secho( "will be used for project.\n" "You can specify another project directory via\n" "`platformio init -d %PATH_TO_THE_PROJECT_DIR%` command.", fg="yellow" )
"command" % id_ ) return value @click.command("init", short_help="Initialize PlatformIO project or update existing") @click.option( "--project-dir", "-d", default=getcwd, type=click.Path( exists=True, file_okay=False, dir_okay=True, writable=True, resolve_path=True ), ) @click.option("-b", "--board", multiple=True, metavar="ID", callback=validate_boards) @click.option("--ide", type=click.Choice(ProjectGenerator.get_supported_ides())) @click.option("-O", "--project-option", multiple=True) @click.option("--env-prefix", default="") @click.option("-s", "--silent", is_flag=True) @click.pass_context def cli( ctx, # pylint: disable=R0913 project_dir, board, ide, project_option, env_prefix, silent, ): if not silent: if project_dir == getcwd():