def _configure(self, parser): parser.add_argument("infile", nargs="*", type=FileType("r"), default=[sys.stdin]) parser.add_argument( "-k", "--keep-going", action="store_true", default=False, help="Continue processing after an error.") parser.set_defaults(func=self.__call__)
def _configure(self, parser): sub = parser.sub() script = sub.add_parser("script", help="Generates a DB creation script") script.set_defaults(func=self.script) script.add_argument( "-f", "--file", type=FileType(mode="w"), help="Optional file to save to. Use '-' for stdout.") script.add_argument("posversion", nargs="?", help=SUPPRESS) script.add_argument("pospatch", nargs="?", help=SUPPRESS) script.add_argument("pospassword", nargs="?", help=SUPPRESS) script.add_argument("--version", help=SUPPRESS) script.add_argument("--patch", help=SUPPRESS) script.add_argument("--password", help="OMERO root password") pw = sub.add_parser( "password", help="Prints SQL command for updating your root password") pw.add_argument("password", nargs="?") pw.set_defaults(func=self.password) pw.add_argument("--user-id", help="User ID to salt into the password. " "Defaults to '0', i.e. 'root'", default="0") for x in (pw, script): x.add_argument("--no-salt", action="store_true", help="Disable the salting of passwords")
def _configure(self, parser): parser.add_argument( "-l", "--list", action="store_true", help="List available commands") parser.add_argument( "file", nargs="*", type=FileType('r'), default=None, help="Read from files or standard in") parser.set_defaults(func=self.__call__) parser.add_login_arguments()
def _configure(self, parser): sub = parser.sub() script = sub.add_parser( "script", help="Generates a DB creation script") script.set_defaults(func=self.script) script.add_argument( "-f", "--file", type=FileType(mode="w"), help="Optional file to save to. Use '-' for stdout.") script.add_argument("dbversion", nargs="?") script.add_argument("dbpatch", nargs="?") script.add_argument("password", nargs="?") pw = sub.add_parser( "password", help="Prints SQL command for updating your root password") pw.add_argument("password", nargs="?") pw.set_defaults(func=self.password)
def __call__(self, string): if not os.path.exists(string): raise ValueError("File does not exist: %s" % string) return FileType.__call__(self, string)
def __call__(self, string): if string != "-" and os.path.exists(string): raise ValueError("File exists: %s" % string) return FileType.__call__(self, string)
def _configure(self, parser): parser.add_argument("infile", nargs="*", type=FileType("r"), default=[sys.stdin]) parser.set_defaults(func=self.__call__)