def main(argv): if len(argv) < 2: # Change to the root dir print "{0} {1}{3}{2}/{2}".format(SET_CMD, ENV_VAR, QUOTE, EQUALS) return 0 else: # Take the first argument only cmd_path = argv[1] if cmd_path == "." or cmd_path == "./": # Special case for '.': do nothing if ENV_VAR in os.environ: print make_cmd_line(os.environ[ENV_VAR]) return 0 else: print make_cmd_line("/") return 0 elif cmd_path == ".." or cmd_path == "../": # Special case for '..': go up one directory if ENV_VAR in os.environ and os.environ[ENV_VAR] and os.environ[ENV_VAR] != "/": parent = os.environ[ENV_VAR][: os.environ[ENV_VAR].rstrip("/").rfind("/")] if not parent: parent = "/" print make_cmd_line(parent) return 0 else: print make_cmd_line("/") return 0 full_path = cmd_path_to_full_path(cmd_path) return cd(cmd_path, full_path)
''' + RTSH_PATH_USAGE + ''' A connection will be made to the port using the default connection settings compatible with the port.''' version = RTSH_VERSION parser = OptionParser(usage=usage, version=version) parser.add_option('-d', '--debug', dest='debug', action='store_true', default=False, help='Print debugging information. \ [Default: %default]') if argv: sys.argv = [sys.argv[0]] + argv try: options, args = parser.parse_args() except OptionError, e: print 'OptionError:', e return 1 if len(args) != 1: print >>sys.stderr, usage return 1 else: path = args[0] full_path = cmd_path_to_full_path(path) return listen_to_port(path, full_path, options, tree) # vim: tw=79
help=\ '''Connection properties. ''') if argv: sys.argv = [sys.argv[0]] + argv try: options, args = parser.parse_args() except OptionError, e: print 'OptionError:', e return 1 if not getattr(options, 'properties'): setattr(options, 'properties', {}) if len(args) != 2: print >>sys.stderr, usage return 1 else: source_path = args[0] dest_path = args[1] source_full_path = cmd_path_to_full_path(source_path) dest_full_path = cmd_path_to_full_path(dest_path) return connect_ports(source_path, source_full_path, dest_path, dest_full_path, options, tree) # vim: tw=79
parser.add_option('-d', '--debug', dest='debug', action='store_true', default=False, help='Print debugging information. \ [Default: %default]') if argv: sys.argv = [sys.argv[0]] + argv try: options, args = parser.parse_args() except OptionError, e: print 'OptionError:', e return 1 if len(args) == 1: # Disconnect all cmd_path = args[0] return disconnect_all(cmd_path, cmd_path_to_full_path(cmd_path), options, tree) elif len(args) == 2: # Disconnect a pair of ports source_path = args[0] dest_path = args[1] source_full_path = cmd_path_to_full_path(source_path) dest_full_path = cmd_path_to_full_path(dest_path) return disconnect_ports(source_path, source_full_path, dest_path, dest_full_path, options, tree) else: print >>sys.stderr, usage return 1 return 1