def parse_arguments(): argv = sys.argv[1:] parser = argparse.ArgumentParser( description= 'Creates a new android package based on catkin and gradle. \n') parser.add_argument('name', nargs=1, help='The name for the package') parser.add_argument('-t', '--target-version', action='store', default='15', help='Android sdk version [15]') parser.add_argument( '-p', '--android-package-name', action='store', default='com.github.rosjava.android.pkg_name', help='Android package name (e.g. com.github.rosjava.android.pkg_name)') parser.add_argument('-a', '--author', action='store', default=utils.author_name(), help='A single author, may be used multiple times') args = parser.parse_args(argv) if args.android_package_name == "com.github.rosjava.android.pkg_name": args.android_package_name = "com.github.rosjava.android.%s" % args.name[ 0].lower() return args
def create_qt_ros_package(package, depends, type): p = os.path.abspath(package) os.makedirs(os.path.join(p,"src")) os.makedirs(os.path.join(p,"include")) os.makedirs(os.path.join(p,"include",package)) os.makedirs(os.path.join(p,"resources")) os.makedirs(os.path.join(p,"resources","images")) os.makedirs(os.path.join(p,"ui")) print "Created qt package directories." # Qt text files templates = get_qt_text_templates(package, type) for filename, template in templates.iteritems(): contents = instantiate_template(template, package, package, author_name(), depends) try: p = os.path.abspath(os.path.join(package, filename)) f = open(p, 'w') f.write(contents) print "Created package file", p finally: f.close() # Qt binary files template_dir = os.path.join(os.path.dirname(__file__),'templates',type) shutil.copy(os.path.join(template_dir,'resources','images','icon.png'), os.path.join(os.path.abspath(package),'resources','images','icon.png'))
def create_cpp_ros_package(): (package, depends) = utils.parse_arguments(['roscpp','std_msgs']) # Make directories p = os.path.abspath(package) os.makedirs(os.path.join(p,"src")) print "Created package directory 'src'" os.makedirs(os.path.join(p,"src","lib")) print "Created package directory 'src/lib'" os.makedirs(os.path.join(p,"include")) print "Created package directory 'include'" os.makedirs(os.path.join(p,"include",package)) print "Created package directory 'include/%s'"%package os.makedirs(os.path.join(p,"launch")) print "Created package directory 'launch'" # Text files manifest_depends = ''.join([' <depend package="%s"/>\n'%d for d in depends]) cmake_depends = ''.join(['%s '%d for d in depends]) templates = get_templates(package) for filename, template in templates.iteritems(): contents = utils.instantiate_template(template, package, package, package, utils.author_name(), manifest_depends, cmake_depends) try: p = os.path.abspath(os.path.join(package, filename)) f = open(p, 'w') f.write(contents.encode('utf-8')) print "Created package file", p finally: f.close() utils.print_concluding_catkin_message(package)
async def on_message(self, message): if message.author.id in cmds.BOT_IDS: return split = message.content.split(' ', 1) # separate mom?[cmd] from args cmd = split[0] args = split[1].split(' ') if len(split) > 1 else None # Retrieve user from database and create if non-existing user = db.user_exists(message.author.id) if not user: db.adduser(message.author.id) prefix = db.get_prefix(message.author.id) # Check if a bot command if not cmd.startswith(f"mom{prefix}"): return # Debugging stuff name = author_name(message.author) print(f"{name} issued {cmd} command. <{args}>") cur_cmd = None try: suffix = cmd[4:] # Get command suffix cur_cmd = COMMANDS[suffix]['cmd'] await cur_cmd(self, message, args) except Exception as error: if not cur_cmd: return await cmds.error_message(message, title=f"Unknown command '{suffix}'") cmds.ERRORS += [time.ctime() + ': ' + str(error)] cmd = cmds.format_cmd(prefix, "report") await cmds.error_message(message, title=f"The command {suffix} failed...", desc=f"Please use ``{cmd}`` if you think it's an unexpected behaviour")
def create_ros_package(type): is_catkin=True if type == 'ros-legacy': is_catkin=False (package, depends) = utils.parse_arguments([], is_catkin) p = os.path.abspath(package) os.makedirs(p) manifest_depends = ''.join([' <depend package="%s"/>\n'%d for d in depends]) cmake_depends = ''.join(['%s '%d for d in depends]) p = os.path.abspath(package) templates = get_ros_text_templates(type) for filename, template in templates.iteritems(): contents = utils.instantiate_template(template, package, package, package, utils.author_name(), manifest_depends, cmake_depends) try: p = os.path.abspath(os.path.join(package, filename)) f = open(p, 'w') f.write(contents.encode('utf-8')) print "Created package file", p finally: f.close() if type == 'ros-legacy': utils.print_concluding_message(package) else: utils.print_concluding_catkin_message(package)
def create_qt_ros_package(package, depends, type): p = os.path.abspath(package) os.makedirs(os.path.join(p, "src")) os.makedirs(os.path.join(p, "include")) os.makedirs(os.path.join(p, "include", package)) os.makedirs(os.path.join(p, "resources")) os.makedirs(os.path.join(p, "resources", "images")) os.makedirs(os.path.join(p, "ui")) print "Created qt package directories." # Qt text files templates = get_qt_text_templates(package, type) for filename, template in templates.iteritems(): contents = instantiate_template(template, package, package, package, author_name(), depends) try: p = os.path.abspath(os.path.join(package, filename)) f = open(p, 'w') f.write(contents) print "Created package file", p finally: f.close() # Qt binary files template_dir = os.path.join(os.path.dirname(__file__), 'templates', type) shutil.copy( os.path.join(template_dir, 'resources', 'images', 'icon.png'), os.path.join(os.path.abspath(package), 'resources', 'images', 'icon.png'))
def create_winros_catkin_package(): (package, depends) = utils.parse_arguments([]) if 'roscpp' in depends: create_cpp_package_directory(package) templates = get_cpp_templates(package) elif 'rospy' in depends: create_py_package_directory(package) templates = get_py_templates(package) else: create_common_package_directory(package) templates = get_common_templates(package) build_depends = ''.join( [' <build_depend>%s</build_depend>\n' % d for d in depends]) run_depends = ''.join( [' <run_depend>%s</run_depend>\n' % d for d in depends]) cmake_depends = ''.join(['%s ' % d for d in depends]) for filename, template in templates.iteritems(): contents = utils.instantiate_template(template, package, package, utils.author_name(), build_depends, run_depends, cmake_depends) try: p = os.path.abspath(os.path.join(package, filename)) f = open(p, 'w') f.write(contents.encode('utf-8')) print "Created package file", p finally: f.close() print "\nPlease edit package.xml, mainpage.dox and CMakeLists.txt to finish creating your package."
def parse_arguments(): argv = sys.argv[1:] parser = argparse.ArgumentParser( description= 'Creates a new rosjava package based on catkin and gradle. \n') parser.add_argument('name', nargs=1, help='The name for the package') parser.add_argument('-a', '--author', action='store', default=utils.author_name(), help='A single author, may be used multiple times') args = parser.parse_args(argv) return args
def parse_arguments(): argv = sys.argv[1:] parser = argparse.ArgumentParser( description='Creates a new rosjava package based on catkin and gradle. \n') parser.add_argument('name', nargs=1, help='The name for the package') parser.add_argument('-a', '--author', action='store', default=utils.author_name(), help='A single author, may be used multiple times') args = parser.parse_args(argv) return args
def populate_repo(repo_path): author = utils.author_name() repo_name = os.path.basename(repo_path) templates = get_templates() for filename, template in templates.iteritems(): contents = instantiate_template(template, repo_name, author) try: p = os.path.abspath(os.path.join(repo_path, filename)) f = open(p, 'w') f.write(contents) console.pretty_print("Created repo file: ", console.cyan) console.pretty_println("%s" % p, console.yellow) finally: f.close()
def populate_repo(repo_path, package_type): author = utils.author_name() repo_name = os.path.basename(repo_path) templates = get_templates(package_type) for filename, template in templates.iteritems(): contents = instantiate_template(template, repo_name, author) try: p = os.path.abspath(os.path.join(repo_path, filename)) f = open(p, 'w') f.write(contents) console.pretty_print("Created repo file: ", console.cyan) console.pretty_println("%s" % p, console.yellow) finally: f.close()
def create_stack(): (stack, depends) = utils.parse_stack_arguments() s = os.path.abspath(stack) os.makedirs(s) manifest_depends = ''.join([' <build_depends>%s</build_depends>\n'%d for d in depends]) cmake_depends = [] # These are currently a bit odd, they're packages templates = get_text_templates() for filename, template in templates.iteritems(): contents = utils.instantiate_template(template, stack, stack, stack, utils.author_name(), manifest_depends, cmake_depends) try: p = os.path.abspath(os.path.join(stack, filename)) f = open(p, 'w') f.write(contents.encode('utf-8')) print "Created stack file", p finally: f.close()
def create_winros_catkin_package(): (package, depends) = utils.parse_arguments(['std_msgs']) create_package_directory(package) templates = get_templates(package) build_depends = ''.join( [' <build_depend>%s</build_depend>\n' % d for d in depends]) run_depends = ''.join( [' <run_depend>%s</run_depend>\n' % d for d in depends]) cmake_depends = ''.join(['%s ' % d for d in depends]) for filename, template in templates.iteritems(): contents = utils.instantiate_template(template, package, package, utils.author_name(), build_depends, run_depends, cmake_depends) try: p = os.path.abspath(os.path.join(package, filename)) f = open(p, 'w') f.write(contents.encode('utf-8')) print "Created package file", p finally: f.close() print "\nPlease edit package.xml, mainpage.dox, CMakeLists.txt, and add the package subdirectory."
def create_qt_ros_package(type): is_catkin=True if type == 'qt-ros-legacy': is_catkin=False #print "Create qt_ros_package(is_catkin:%r)" % is_catkin (package, depends) = utils.parse_arguments(['qt_build','roscpp'], is_catkin) # Make directories p = os.path.abspath(package) os.makedirs(os.path.join(p,"src")) os.makedirs(os.path.join(p,"include")) os.makedirs(os.path.join(p,"include",package)) os.makedirs(os.path.join(p,"resources")) os.makedirs(os.path.join(p,"resources","images")) os.makedirs(os.path.join(p,"ui")) print "Created qt package directories." # Qt text files manifest_depends = ''.join([' <depend package="%s"/>\n'%d for d in depends]) cmake_depends = ''.join(['%s '%d for d in depends]) templates = get_qt_text_templates(package, type) for filename, template in templates.iteritems(): contents = utils.instantiate_template(template, package, package, package, utils.author_name(), manifest_depends, cmake_depends) try: p = os.path.abspath(os.path.join(package, filename)) f = open(p, 'w') f.write(contents.encode('utf-8')) print "Created package file", p finally: f.close() # Qt binary files template_dir = os.path.join(os.path.dirname(__file__),'templates',type) shutil.copy(os.path.join(template_dir,'resources','images','icon.png'), os.path.join(os.path.abspath(package),'resources','images','icon.png')) if type == 'qt-ros-legacy': utils.print_concluding_message(package) else: utils.print_concluding_catkin_message(package)
def parse_arguments(): argv = sys.argv[1:] parser = argparse.ArgumentParser( description='Creates a new android package based on catkin and gradle. \n') parser.add_argument('name', nargs=1, help='The name for the package') parser.add_argument('-s', '--sdk-version', action='store', default='18.1.1', help='Android sdk version [18.1.1]') parser.add_argument('-p', '--android-package-name', action='store', default='com.github.rosjava.android.pkg_name', help='Android package name (e.g. com.github.rosjava.android.pkg_name)') parser.add_argument('-a', '--author', action='store', default=utils.author_name(), help='A single author, may be used multiple times') args = parser.parse_args(argv) if args.android_package_name == "com.github.rosjava.android.pkg_name": args.android_package_name = "com.github.rosjava.android.%s" % args.name[0].lower() return args
def create_comms_package(type): (package, depends) = utils.parse_arguments(['std_msgs']) # Make directories p = os.path.abspath(package) os.makedirs(os.path.join(p,"msg")) os.makedirs(os.path.join(p,"srv")) print "Created package directories." # Text files manifest_depends = ''.join([' <depend package="%s"/>\n'%d for d in depends]) cmake_depends = ''.join(['%s '%d for d in depends]) templates = get_text_templates(package, type) for filename, template in templates.iteritems(): contents = utils.instantiate_template(template, package, package, package, utils.author_name(), manifest_depends, cmake_depends) try: p = os.path.abspath(os.path.join(package, filename)) f = open(p, 'w') f.write(contents.encode('utf-8')) print "Created package file", p finally: f.close() utils.print_concluding_catkin_message(package)