bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def arguments(): """Defines the command line arguments for the script.""" main_desc = ("Mirror a remote FTP directory into a local directory or vice " "versa through the lftp program") subs_desc = "Select a running mode from the following:" epilog = ("For detailed help for each mode, select a mode followed by help " "option, e.g.:{0}{0}%(prog)s shell -h").format(os.linesep) cron_use = "%(prog)s [-h]" shell_use = ("%(prog)s site remote local [options]{0}{0}By default " "downloads the changes from remote FTP directory to local " "directory.{0}To upload changes from local to remote FTP, use " "the 'r, --reverse' option").format(os.linesep) file_use = ("%(prog)s config_file [-h]{0}{0}The structure of the " "config file (a simple text file) is as follows:{0}{0}[section]" "{0}site = {{ftp server URL or IP}}{0}port = (ftp server port)" "{0}remote = {{remote directory}}{0}local = {{local directory}}" "{0}user = (ftp server username){0}password = (user password " "encoded in base64){0}options = (other options){0}{0}Section is" " a name that defines the mirror operation. Usually is the ftp " "server's name or directory' name. Useful for distinguish one " "mirror operation from others. Write one section for each " "mirror action with no limits in the number of sections.{0}{0}" "Values between curly brackets '{{}}' are required arguments " "and values between brackets '()' are optional arguments. If " "don't want optional arguments, left them blank. In case you do" " not specify a username and password, you must add the '-a' " "option which specifies that the connection is made with the " "anonymous user.{0}{0}The order of arguments doesn't matter, " "but all are needed.{0}{0}").format(os.linesep) parser = ArgumentParser(description=main_desc, epilog=epilog) subparsers = parser.add_subparsers(title="running modes", description=subs_desc) cron = subparsers.add_parser("cron", help="ideal to run as a scheduled task" ". Takes arguments from parameters defined " "within the script", usage=cron_use) cron.add_argument("cron", action="store_true", help=SUPPRESS, default=SUPPRESS) cron.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg = subparsers.add_parser("cfg", help="ideal for mirror multiple sites/" "directories. Imports the arguments from a " "config file", usage=file_use) cfg.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("cfg", action="store_true", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("config_file", help="config file to import arguments") shell = subparsers.add_parser("shell", help="usual mode, takes arguments " "from the command line ", usage=shell_use) shell.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("site", help="the ftp server (URL or IP)") shell.add_argument("remote", help="the remote directory") shell.add_argument("local", help="the local directory") auth = shell.add_mutually_exclusive_group(required=True) auth.add_argument("-l", "--login", dest="login", nargs=2, help="the ftp account's username and password", metavar=("user", "password")) auth.add_argument("-a", "--anon", action="store_true", dest="anonymous", help="set user as anonymous", default=False) shell.add_argument("-p", "--port", dest="port", default="", help="the ftp server port", metavar="port") shell.add_argument("-s", "--secure", action="store_const", const="s", dest="secure", default="", help="use the sftp protocol instead of ftp") shell.add_argument("-e", "--erase", action="store_const", const="e", dest="erase", default="", help="delete files not present at target site") shell.add_argument("-n", "--newer", action="store_const", const="n", dest="newer", default="", help="download only newer files") shell.add_argument("-P", "--parallel", action="store_const", const="P", dest="parallel", default="", help="download files in parallel") shell.add_argument("-r", "--reverse", action="store_const", const="R", dest="reverse", default="", help="reverse, upload files from local to remote") shell.add_argument("--delete-first", action="store_const", const=" --delete-first", dest="del_first", default="", help="delete old files before transferring new ones") shell.add_argument("--depth-first", action="store_const", const=" --depth-first", dest="depth_first", default="", help="descend into subdirectories, before transfer files") shell.add_argument("--no-empty-dirs", action="store_const", const=" --no-empty-dirs", dest="no_empty_dir", default="", help="don't create empty dirs (needs --depth-first)") shell.add_argument("--no-recursion", action="store_const", const=" --no-recursion", dest="no_recursion", default="", help="don't go to subdirectories") shell.add_argument("--dry-run", action="store_const", const=" --dry-run", dest="dry_run", default="", help="simulation, don't execute anything. Writes to log") shell.add_argument("--use-cache", action="store_const", const=" --use-cache", dest="use_cache", default="", help="use cached directory listings") shell.add_argument("--del-source", action="store_const", const=" --Remove-source-files", dest="del_source", default="", help="remove files (no dirs) after transfer (Caution!)") shell.add_argument("--only-missing", action="store_const", const=" --only-missing", dest="missing", default="", help="download only missing files") shell.add_argument("--only-existing", action="store_const", const=" --only-existing", dest="existing", default="", help="download only files already existing at target") shell.add_argument("--loop", action="store_const", const=" --loop", dest="loop", default="", help="Loop until no changes found") shell.add_argument("--ignore-size", action="store_const", const=" --ignore-size", dest="size", default="", help="ignore size when deciding whether to download") shell.add_argument("--ignore-time", action="store_const", const=" --ignore-time", dest="time", default="", help="ignore time when deciding whether to download") shell.add_argument("--no-perms", action="store_const", const=" --no-perms", dest="no_perms", default="", help="don't set cfg permissions") shell.add_argument("--no-umask", action="store_const", const=" --no-umask", dest="no_umask", default="", help="don't apply umask to cfg modes") shell.add_argument("--no-symlinks", action="store_const", const=" --no-symlinks", dest="no_symlinks", default="", help="don't create symbolic links") shell.add_argument("--allow-suid", action="store_const", const=" --allow-suid", dest="suid", default="", help="set suid/sgid bits according to remote site") shell.add_argument("--allow-chown", action="store_const", const=" --allow-chown", dest="chown", default="", help="try to set owner and group on files") shell.add_argument("--dereference", action="store_const", const=" --dereference", dest="dereference", default="", help="download symbolic links as files") shell.add_argument("--exclude-glob", dest="exc_glob", default="", metavar="GP", help="exclude matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("--include-glob", dest="inc_glob", default="", metavar="GP", help="include matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("-q", "--quiet", action="store_true", dest="quiet", help="the detailed shell process is no " "displayed, but is added to the log", default=False) shell.add_argument("--no-compress", action="store_true", dest="no_compress", help="don't create daily archive " "files", default=False) shell.add_argument("--no-email", action="store_true", dest="no_email", help="no sends email with the log", default=False) shell.add_argument("--smtp_server", dest="smtp_server", default="localhost", metavar="server", help="set a smtp server") shell.add_argument("--smtp_user", dest="smtp_user", default="", metavar="user", help="the smtp server username") shell.add_argument("--smtp_pass", dest="smtp_pass", default="", metavar="password", help="the smtp server password") shell.add_argument("--from_addr", dest="from_addr", default="", metavar="email", help="sender's email address") shell.add_argument("--to_addrs", dest="to_addrs", default="", nargs='+', metavar="email", help="a list of receiver(s)' email address(es)") parser.add_argument("-v", "--version", action="version", version="%(prog)s {0}".format(__version__), help="show program's version number and exit") return parser
|
def arguments(): """Defines the command line arguments for the script.""" main_desc = ("Mirror a remote FTP directory into a local directory or vice " "versa through the lftp program") subs_desc = "Select a running mode from the following:" epilog = ("For detailed help for each mode, select a mode followed by help " "option, e.g.:{0}{0}%(prog)s shell -h").format(os.linesep) cron_use = "%(prog)s [-h]" shell_use = ("%(prog)s site remote local [options]{0}{0}By default " "downloads the changes from remote FTP directory to local " "directory.{0}To upload changes from local to remote FTP, use " "the 'r, --reverse' option").format(os.linesep) file_use = ("%(prog)s config_file [-h]{0}{0}The structure of the " "config file (a simple text file) is as follows:{0}{0}[section]" "{0}site = {{ftp server URL or IP}}{0}port = (ftp server port)" "{0}remote = {{remote directory}}{0}local = {{local directory}}" "{0}user = (ftp server username){0}password = (user password " "encoded in base64){0}options = (other options){0}{0}Section is" " a name that defines the mirror operation. Usually is the ftp " "server's name or directory' name. Useful for distinguish one " "mirror operation from others. Write one section for each " "mirror action with no limits in the number of sections.{0}{0}" "Values between curly brackets '{{}}' are required arguments " "and values between brackets '()' are optional arguments. If " "don't want optional arguments, left them blank. In case you do" " not specify a username and password, you must add the '-a' " "option which specifies that the connection is made with the " "anonymous user.{0}{0}The order of arguments doesn't matter, " "but all are needed.{0}{0}").format(os.linesep) parser = ArgumentParser(description=main_desc, epilog=epilog) subparsers = parser.add_subparsers(title="running modes", description=subs_desc) cron = subparsers.add_parser("cron", help="ideal to run as a scheduled task" ". Takes arguments from parameters defined " "within the script", usage=cron_use) cron.add_argument("cron", action="store_true", help=SUPPRESS, default=SUPPRESS) cron.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg = subparsers.add_parser("cfg", help="ideal for mirror multiple sites/" "directories. Imports the arguments from a " "config file", usage=file_use) cfg.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("cfg", action="store_true", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("config_file", help="config file to import arguments") shell = subparsers.add_parser("shell", help="usual mode, takes arguments " "from the command line ", usage=shell_use) shell.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("site", help="the ftp server (URL or IP)") shell.add_argument("remote", help="the remote directory") shell.add_argument("local", help="the local directory") auth = shell.add_mutually_exclusive_group(required=True) auth.add_argument("-l", "--login", dest="login", nargs=2, help="the ftp account's username and password", metavar=("user", "password")) auth.add_argument("-a", "--anon", action="store_true", dest="anonymous", help="set user as anonymous", default=False) shell.add_argument("-p", "--port", dest="port", default="", help="the ftp server port", metavar="port") shell.add_argument("-s", "--secure", action="store_const", const="s", dest="secure", default="", help="use the sftp protocol instead of ftp") shell.add_argument("-e", "--erase", action="store_const", const="e", dest="erase", default="", help="delete files not present at target site") shell.add_argument("-n", "--newer", action="store_const", const="n", dest="newer", default="", help="download only newer files") shell.add_argument("-P", "--parallel", action="store_const", const="P", dest="parallel", default="", help="download files in parallel") shell.add_argument("-r", "--reverse", action="store_const", const="R", dest="reverse", default="", help="reverse, upload files from local to remote") shell.add_argument("--delete-first", action="store_const", const=" --delete-first", dest="del_first", default="", help="delete old files before transferring new ones") shell.add_argument("--depth-first", action="store_const", const=" --depth-first", dest="depth_first", default="", help="descend into subdirectories, before transfer files") shell.add_argument("--no-empty-dirs", action="store_const", const=" --no-empty-dirs", dest="no_empty_dir", default="", help="don't create empty dirs (needs --depth-first)") shell.add_argument("--no-recursion", action="store_const", const=" --no-recursion", dest="no_recursion", default="", help="don't go to subdirectories") shell.add_argument("--dry-run", action="store_const", const=" --dry-run", dest="dry_run", default="", help="simulation, don't execute anything. Writes to log") shell.add_argument("--use-cache", action="store_const", const=" --use-cache", dest="use_cache", default="", help="use cached directory listings") shell.add_argument("--del-source", action="store_const", const=" --Remove-source-files", dest="del_source", default="", help="remove files (no dirs) after transfer (Caution!)") shell.add_argument("--only-missing", action="store_const", const=" --only-missing", dest="missing", default="", help="download only missing files") shell.add_argument("--only-existing", action="store_const", const=" --only-existing", dest="existing", default="", help="download only files already existing at target") shell.add_argument("--loop", action="store_const", const=" --loop", dest="loop", default="", help="Loop until no changes found") shell.add_argument("--ignore-size", action="store_const", const=" --ignore-size", dest="size", default="", help="ignore size when deciding whether to download") shell.add_argument("--ignore-time", action="store_const", const=" --ignore-time", dest="time", default="", help="ignore time when deciding whether to download") shell.add_argument("--no-perms", action="store_const", const=" --no-perms", dest="no_perms", default="", help="don't set file permissions") shell.add_argument("--no-umask", action="store_const", const=" --no-umask", dest="no_umask", default="", help="don't apply umask to cfg modes") shell.add_argument("--no-symlinks", action="store_const", const=" --no-symlinks", dest="no_symlinks", default="", help="don't create symbolic links") shell.add_argument("--allow-suid", action="store_const", const=" --allow-suid", dest="suid", default="", help="set suid/sgid bits according to remote site") shell.add_argument("--allow-chown", action="store_const", const=" --allow-chown", dest="chown", default="", help="try to set owner and group on files") shell.add_argument("--dereference", action="store_const", const=" --dereference", dest="dereference", default="", help="download symbolic links as files") shell.add_argument("--exclude-glob", dest="exc_glob", default="", metavar="GP", help="exclude matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("--include-glob", dest="inc_glob", default="", metavar="GP", help="include matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("-q", "--quiet", action="store_true", dest="quiet", help="the detailed shell process is no " "displayed, but is added to the log", default=False) shell.add_argument("--no-compress", action="store_true", dest="no_compress", help="don't create daily archive " "files", default=False) shell.add_argument("--no-email", action="store_true", dest="no_email", help="no sends email with the log", default=False) shell.add_argument("--smtp_server", dest="smtp_server", default="localhost", metavar="server", help="set a smtp server") shell.add_argument("--smtp_user", dest="smtp_user", default="", metavar="user", help="the smtp server username") shell.add_argument("--smtp_pass", dest="smtp_pass", default="", metavar="password", help="the smtp server password") shell.add_argument("--from_addr", dest="from_addr", default="", metavar="email", help="sender's email address") shell.add_argument("--to_addrs", dest="to_addrs", default="", nargs='+', metavar="email", help="a list of receiver(s)' email address(es)") parser.add_argument("-v", "--version", action="version", version="%(prog)s {0}".format(__version__), help="show program's version number and exit") return parser
| 473,700
|
def arguments(): """Defines the command line arguments for the script.""" main_desc = ("Mirror a remote FTP directory into a local directory or vice " "versa through the lftp program") subs_desc = "Select a running mode from the following:" epilog = ("For detailed help for each mode, select a mode followed by help " "option, e.g.:{0}{0}%(prog)s shell -h").format(os.linesep) cron_use = "%(prog)s [-h]" shell_use = ("%(prog)s site remote local [options]{0}{0}By default " "downloads the changes from remote FTP directory to local " "directory.{0}To upload changes from local to remote FTP, use " "the 'r, --reverse' option").format(os.linesep) file_use = ("%(prog)s config_file [-h]{0}{0}The structure of the " "config file (a simple text file) is as follows:{0}{0}[section]" "{0}site = {{ftp server URL or IP}}{0}port = (ftp server port)" "{0}remote = {{remote directory}}{0}local = {{local directory}}" "{0}user = (ftp server username){0}password = (user password " "encoded in base64){0}options = (other options){0}{0}Section is" " a name that defines the mirror operation. Usually is the ftp " "server's name or directory' name. Useful for distinguish one " "mirror operation from others. Write one section for each " "mirror action with no limits in the number of sections.{0}{0}" "Values between curly brackets '{{}}' are required arguments " "and values between brackets '()' are optional arguments. If " "don't want optional arguments, left them blank. In case you do" " not specify a username and password, you must add the '-a' " "option which specifies that the connection is made with the " "anonymous user.{0}{0}The order of arguments doesn't matter, " "but all are needed.{0}{0}").format(os.linesep) parser = ArgumentParser(description=main_desc, epilog=epilog) subparsers = parser.add_subparsers(title="running modes", description=subs_desc) cron = subparsers.add_parser("cron", help="ideal to run as a scheduled task" ". Takes arguments from parameters defined " "within the script", usage=cron_use) cron.add_argument("cron", action="store_true", help=SUPPRESS, default=SUPPRESS) cron.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg = subparsers.add_parser("cfg", help="ideal for mirror multiple sites/" "directories. Imports the arguments from a " "config file", usage=file_use) cfg.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("cfg", action="store_true", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("config_file", help="config file to import arguments") shell = subparsers.add_parser("shell", help="usual mode, takes arguments " "from the command line ", usage=shell_use) shell.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("site", help="the ftp server (URL or IP)") shell.add_argument("remote", help="the remote directory") shell.add_argument("local", help="the local directory") auth = shell.add_mutually_exclusive_group(required=True) auth.add_argument("-l", "--login", dest="login", nargs=2, help="the ftp account's username and password", metavar=("user", "password")) auth.add_argument("-a", "--anon", action="store_true", dest="anonymous", help="set user as anonymous", default=False) shell.add_argument("-p", "--port", dest="port", default="", help="the ftp server port", metavar="port") shell.add_argument("-s", "--secure", action="store_const", const="s", dest="secure", default="", help="use the sftp protocol instead of ftp") shell.add_argument("-e", "--erase", action="store_const", const="e", dest="erase", default="", help="delete files not present at target site") shell.add_argument("-n", "--newer", action="store_const", const="n", dest="newer", default="", help="download only newer files") shell.add_argument("-P", "--parallel", action="store_const", const="P", dest="parallel", default="", help="download files in parallel") shell.add_argument("-r", "--reverse", action="store_const", const="R", dest="reverse", default="", help="reverse, upload files from local to remote") shell.add_argument("--delete-first", action="store_const", const=" --delete-first", dest="del_first", default="", help="delete old files before transferring new ones") shell.add_argument("--depth-first", action="store_const", const=" --depth-first", dest="depth_first", default="", help="descend into subdirectories, before transfer files") shell.add_argument("--no-empty-dirs", action="store_const", const=" --no-empty-dirs", dest="no_empty_dir", default="", help="don't create empty dirs (needs --depth-first)") shell.add_argument("--no-recursion", action="store_const", const=" --no-recursion", dest="no_recursion", default="", help="don't go to subdirectories") shell.add_argument("--dry-run", action="store_const", const=" --dry-run", dest="dry_run", default="", help="simulation, don't execute anything. Writes to log") shell.add_argument("--use-cache", action="store_const", const=" --use-cache", dest="use_cache", default="", help="use cached directory listings") shell.add_argument("--del-source", action="store_const", const=" --Remove-source-files", dest="del_source", default="", help="remove files (no dirs) after transfer (Caution!)") shell.add_argument("--only-missing", action="store_const", const=" --only-missing", dest="missing", default="", help="download only missing files") shell.add_argument("--only-existing", action="store_const", const=" --only-existing", dest="existing", default="", help="download only files already existing at target") shell.add_argument("--loop", action="store_const", const=" --loop", dest="loop", default="", help="Loop until no changes found") shell.add_argument("--ignore-size", action="store_const", const=" --ignore-size", dest="size", default="", help="ignore size when deciding whether to download") shell.add_argument("--ignore-time", action="store_const", const=" --ignore-time", dest="time", default="", help="ignore time when deciding whether to download") shell.add_argument("--no-perms", action="store_const", const=" --no-perms", dest="no_perms", default="", help="don't set cfg permissions") shell.add_argument("--no-umask", action="store_const", const=" --no-umask", dest="no_umask", default="", help="don't apply umask to cfg modes") shell.add_argument("--no-symlinks", action="store_const", const=" --no-symlinks", dest="no_symlinks", default="", help="don't create symbolic links") shell.add_argument("--allow-suid", action="store_const", const=" --allow-suid", dest="suid", default="", help="set suid/sgid bits according to remote site") shell.add_argument("--allow-chown", action="store_const", const=" --allow-chown", dest="chown", default="", help="try to set owner and group on files") shell.add_argument("--dereference", action="store_const", const=" --dereference", dest="dereference", default="", help="download symbolic links as files") shell.add_argument("--exclude-glob", dest="exc_glob", default="", metavar="GP", help="exclude matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("--include-glob", dest="inc_glob", default="", metavar="GP", help="include matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("-q", "--quiet", action="store_true", dest="quiet", help="the detailed shell process is no " "displayed, but is added to the log", default=False) shell.add_argument("--no-compress", action="store_true", dest="no_compress", help="don't create daily archive " "files", default=False) shell.add_argument("--no-email", action="store_true", dest="no_email", help="no sends email with the log", default=False) shell.add_argument("--smtp_server", dest="smtp_server", default="localhost", metavar="server", help="set a smtp server") shell.add_argument("--smtp_user", dest="smtp_user", default="", metavar="user", help="the smtp server username") shell.add_argument("--smtp_pass", dest="smtp_pass", default="", metavar="password", help="the smtp server password") shell.add_argument("--from_addr", dest="from_addr", default="", metavar="email", help="sender's email address") shell.add_argument("--to_addrs", dest="to_addrs", default="", nargs='+', metavar="email", help="a list of receiver(s)' email address(es)") parser.add_argument("-v", "--version", action="version", version="%(prog)s {0}".format(__version__), help="show program's version number and exit") return parser
|
def arguments(): """Defines the command line arguments for the script.""" main_desc = ("Mirror a remote FTP directory into a local directory or vice " "versa through the lftp program") subs_desc = "Select a running mode from the following:" epilog = ("For detailed help for each mode, select a mode followed by help " "option, e.g.:{0}{0}%(prog)s shell -h").format(os.linesep) cron_use = "%(prog)s [-h]" shell_use = ("%(prog)s site remote local [options]{0}{0}By default " "downloads the changes from remote FTP directory to local " "directory.{0}To upload changes from local to remote FTP, use " "the 'r, --reverse' option").format(os.linesep) file_use = ("%(prog)s config_file [-h]{0}{0}The structure of the " "config file (a simple text file) is as follows:{0}{0}[section]" "{0}site = {{ftp server URL or IP}}{0}port = (ftp server port)" "{0}remote = {{remote directory}}{0}local = {{local directory}}" "{0}user = (ftp server username){0}password = (user password " "encoded in base64){0}options = (other options){0}{0}Section is" " a name that defines the mirror operation. Usually is the ftp " "server's name or directory' name. Useful for distinguish one " "mirror operation from others. Write one section for each " "mirror action with no limits in the number of sections.{0}{0}" "Values between curly brackets '{{}}' are required arguments " "and values between brackets '()' are optional arguments. If " "don't want optional arguments, left them blank. In case you do" " not specify a username and password, you must add the '-a' " "option which specifies that the connection is made with the " "anonymous user.{0}{0}The order of arguments doesn't matter, " "but all are needed.{0}{0}").format(os.linesep) parser = ArgumentParser(description=main_desc, epilog=epilog) subparsers = parser.add_subparsers(title="running modes", description=subs_desc) cron = subparsers.add_parser("cron", help="ideal to run as a scheduled task" ". Takes arguments from parameters defined " "within the script", usage=cron_use) cron.add_argument("cron", action="store_true", help=SUPPRESS, default=SUPPRESS) cron.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg = subparsers.add_parser("cfg", help="ideal for mirror multiple sites/" "directories. Imports the arguments from a " "config file", usage=file_use) cfg.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("cfg", action="store_true", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("config_file", help="config file to import arguments") shell = subparsers.add_parser("shell", help="usual mode, takes arguments " "from the command line ", usage=shell_use) shell.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("site", help="the ftp server (URL or IP)") shell.add_argument("remote", help="the remote directory") shell.add_argument("local", help="the local directory") auth = shell.add_mutually_exclusive_group(required=True) auth.add_argument("-l", "--login", dest="login", nargs=2, help="the ftp account's username and password", metavar=("user", "password")) auth.add_argument("-a", "--anon", action="store_true", dest="anonymous", help="set user as anonymous", default=False) shell.add_argument("-p", "--port", dest="port", default="", help="the ftp server port", metavar="port") shell.add_argument("-s", "--secure", action="store_const", const="s", dest="secure", default="", help="use the sftp protocol instead of ftp") shell.add_argument("-e", "--erase", action="store_const", const="e", dest="erase", default="", help="delete files not present at target site") shell.add_argument("-n", "--newer", action="store_const", const="n", dest="newer", default="", help="download only newer files") shell.add_argument("-P", "--parallel", action="store_const", const="P", dest="parallel", default="", help="download files in parallel") shell.add_argument("-r", "--reverse", action="store_const", const="R", dest="reverse", default="", help="reverse, upload files from local to remote") shell.add_argument("--delete-first", action="store_const", const=" --delete-first", dest="del_first", default="", help="delete old files before transferring new ones") shell.add_argument("--depth-first", action="store_const", const=" --depth-first", dest="depth_first", default="", help="descend into subdirectories, before transfer files") shell.add_argument("--no-empty-dirs", action="store_const", const=" --no-empty-dirs", dest="no_empty_dir", default="", help="don't create empty dirs (needs --depth-first)") shell.add_argument("--no-recursion", action="store_const", const=" --no-recursion", dest="no_recursion", default="", help="don't go to subdirectories") shell.add_argument("--dry-run", action="store_const", const=" --dry-run", dest="dry_run", default="", help="simulation, don't execute anything. Writes to log") shell.add_argument("--use-cache", action="store_const", const=" --use-cache", dest="use_cache", default="", help="use cached directory listings") shell.add_argument("--del-source", action="store_const", const=" --Remove-source-files", dest="del_source", default="", help="remove files (no dirs) after transfer (Caution!)") shell.add_argument("--only-missing", action="store_const", const=" --only-missing", dest="missing", default="", help="download only missing files") shell.add_argument("--only-existing", action="store_const", const=" --only-existing", dest="existing", default="", help="download only files already existing at target") shell.add_argument("--loop", action="store_const", const=" --loop", dest="loop", default="", help="Loop until no changes found") shell.add_argument("--ignore-size", action="store_const", const=" --ignore-size", dest="size", default="", help="ignore size when deciding whether to download") shell.add_argument("--ignore-time", action="store_const", const=" --ignore-time", dest="time", default="", help="ignore time when deciding whether to download") shell.add_argument("--no-perms", action="store_const", const=" --no-perms", dest="no_perms", default="", help="don't set cfg permissions") shell.add_argument("--no-umask", action="store_const", const=" --no-umask", dest="no_umask", default="", help="don't apply umask to file modes") shell.add_argument("--no-symlinks", action="store_const", const=" --no-symlinks", dest="no_symlinks", default="", help="don't create symbolic links") shell.add_argument("--allow-suid", action="store_const", const=" --allow-suid", dest="suid", default="", help="set suid/sgid bits according to remote site") shell.add_argument("--allow-chown", action="store_const", const=" --allow-chown", dest="chown", default="", help="try to set owner and group on files") shell.add_argument("--dereference", action="store_const", const=" --dereference", dest="dereference", default="", help="download symbolic links as files") shell.add_argument("--exclude-glob", dest="exc_glob", default="", metavar="GP", help="exclude matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("--include-glob", dest="inc_glob", default="", metavar="GP", help="include matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("-q", "--quiet", action="store_true", dest="quiet", help="the detailed shell process is no " "displayed, but is added to the log", default=False) shell.add_argument("--no-compress", action="store_true", dest="no_compress", help="don't create daily archive " "files", default=False) shell.add_argument("--no-email", action="store_true", dest="no_email", help="no sends email with the log", default=False) shell.add_argument("--smtp_server", dest="smtp_server", default="localhost", metavar="server", help="set a smtp server") shell.add_argument("--smtp_user", dest="smtp_user", default="", metavar="user", help="the smtp server username") shell.add_argument("--smtp_pass", dest="smtp_pass", default="", metavar="password", help="the smtp server password") shell.add_argument("--from_addr", dest="from_addr", default="", metavar="email", help="sender's email address") shell.add_argument("--to_addrs", dest="to_addrs", default="", nargs='+', metavar="email", help="a list of receiver(s)' email address(es)") parser.add_argument("-v", "--version", action="version", version="%(prog)s {0}".format(__version__), help="show program's version number and exit") return parser
| 473,701
|
def bes_unit_size(f_size): """Get a size in bytes and convert it for the best unit for readability. Return two values: (int) bu_size -- Size of the path converted to the best unit for easy read (str) unit -- The units (IEC) for bu_size (from bytes(2^0) to YiB(2^80)) """ for exp in range(0, 90 , 10): bu_size = f_size / pow(2.0, exp) if int(bu_size) < 2 ** 10: unit = {0:'bytes', 10:'KiB', 20:'MiB', 30:'GiB', 40:'TiB', 50:'PiB', 60:'EiB', 70:'ZiB', 80:'YiB'}[exp] break return {'s':bu_size, 'u':unit}
|
def best_unit_size(bytes_size): """Get a size in bytes & convert it to the best IEC prefix for readability. Return a dictionary with three pair of keys/values: 's' -- (float) Size of path converted to the best unit for easy read 'u' -- (str) The prefix (IEC) for s (from bytes(2^0) to YiB(2^80)) 'b' -- (int / long) The original size in bytes """ for exp in range(0, 90 , 10): bu_size = f_size / pow(2.0, exp) if int(bu_size) < 2 ** 10: unit = {0:'bytes', 10:'KiB', 20:'MiB', 30:'GiB', 40:'TiB', 50:'PiB', 60:'EiB', 70:'ZiB', 80:'YiB'}[exp] break return {'s':bu_size, 'u':unit}
| 473,702
|
def bes_unit_size(f_size): """Get a size in bytes and convert it for the best unit for readability. Return two values: (int) bu_size -- Size of the path converted to the best unit for easy read (str) unit -- The units (IEC) for bu_size (from bytes(2^0) to YiB(2^80)) """ for exp in range(0, 90 , 10): bu_size = f_size / pow(2.0, exp) if int(bu_size) < 2 ** 10: unit = {0:'bytes', 10:'KiB', 20:'MiB', 30:'GiB', 40:'TiB', 50:'PiB', 60:'EiB', 70:'ZiB', 80:'YiB'}[exp] break return {'s':bu_size, 'u':unit}
|
def bes_unit_size(f_size): """Get a size in bytes and convert it for the best unit for readability. Return two values: (int) bu_size -- Size of the path converted to the best unit for easy read (str) unit -- The units (IEC) for bu_size (from bytes(2^0) to YiB(2^80)) """ for exp in range(0, 90 , 10): bu_size = abs(bytes_size) / pow(2.0, exp) if int(bu_size) < 2 ** 10: unit = {0:'bytes', 10:'KiB', 20:'MiB', 30:'GiB', 40:'TiB', 50:'PiB', 60:'EiB', 70:'ZiB', 80:'YiB'}[exp] break return {'s':bu_size, 'u':unit}
| 473,703
|
def bes_unit_size(f_size): """Get a size in bytes and convert it for the best unit for readability. Return two values: (int) bu_size -- Size of the path converted to the best unit for easy read (str) unit -- The units (IEC) for bu_size (from bytes(2^0) to YiB(2^80)) """ for exp in range(0, 90 , 10): bu_size = f_size / pow(2.0, exp) if int(bu_size) < 2 ** 10: unit = {0:'bytes', 10:'KiB', 20:'MiB', 30:'GiB', 40:'TiB', 50:'PiB', 60:'EiB', 70:'ZiB', 80:'YiB'}[exp] break return {'s':bu_size, 'u':unit}
|
def bes_unit_size(f_size): """Get a size in bytes and convert it for the best unit for readability. Return two values: (int) bu_size -- Size of the path converted to the best unit for easy read (str) unit -- The units (IEC) for bu_size (from bytes(2^0) to YiB(2^80)) """ for exp in range(0, 90 , 10): bu_size = f_size / pow(2.0, exp) if int(bu_size) < 2 ** 10: unit = {0:'bytes', 10:'KiB', 20:'MiB', 30:'GiB', 40:'TiB', 50:'PiB', 60:'EiB', 70:'ZiB', 80:'YiB'}[exp] break return {'s':bu_size, 'u':unit, 'b':bytes_size}
| 473,704
|
def get_size(the_path): """Get size of a directory tree or a file in bytes.""" path_size = 0 if os.path.isfile(the_path): path_size = os.path.getsize(the_path) for path, dirs, files in os.walk(the_path): for fil in files: filename = os.path.join(path, fil) path_size += os.path.getsize(filename) return path_size
|
def get_size(the_path): """Get size of a directory tree or a file in bytes.""" path_size = 0 for path, directories, files in os.walk(the_path): for filename in files: path_size += os.lstat(os.path.join(path, filename)).st_size for directory in directories: path_size += os.lstat(os.path.join(path, directory)).st_size path_size += os.path.getsize(the_path) return path_size
| 473,705
|
def mirror(args, log): """Mirror the directories.""" user = '' if args.anonymous else ' '.join(args.login) local, remote = os.path.normpath(args.local), os.path.normpath(args.remote) port = '-p {0}'.format(args.port) if args.port else '' include = ' --include-glob {0}'.format(args.inc_glob) if args.inc_glob else '' exclude = ' --exclude-glob {0}'.format(args.exc_glob) if args.exc_glob else '' url = 'http://code.joedicastro.com/lftp-mirror' msg = 'Connected to {1} as {2}{0}'.format(os.linesep, args.site, 'anonymous' if args.anonymous else args.login[0]) msg += 'Mirror {0} to {1}'.format(local if args.reverse else remote, remote if args.reverse else local) log.header(url, msg) log.time('Start time') notify('Mirroring with {0}...'.format(args.site), 'sync') if not os.path.exists(local): os.mkdir(local) log.list('Created new directory', local) os.chdir(os.path.join(local, os.pardir)) # create the script file to import with lftp scp_args = ('-vvv' + args.erase + args.newer + args.parallel + args.reverse + args.del_first + args.depth_first + args.no_empty_dir + args.no_recursion + args.dry_run + args.use_cache + args.del_source + args.missing + args.existing + args.loop + args.size + args.time + args.no_perms + args.no_umask + args.no_symlinks + args.suid + args.chown + args.dereference + exclude + include) with open('ftpscript', 'w') as script: lines = ('open {0}ftp://{1} {2}'.format(args.secure, args.site, port), 'user {0}'.format(user), 'mirror {0} {1} {2}'.format(scp_args, local if args.reverse else remote, remote if args.reverse else local), 'exit') script.write(os.linesep.join(lines)) # mirror cmd = ['lftp', '-d', '-f', script.name] sync = Popen(cmd, stdout=PIPE, stderr={True:STDOUT, False:None}[args.quiet]) # end mirroring log.list('lftp output', ''.join(sync.stdout.readlines())) # compress the dir and create a .gz file with date if not args.reverse and not args.no_compress: notify('Compressing folder...', 'info') log.list('Rotate compressed copies', compress(local)) # end compress gz_size = sum([get_size(gz) for gz in glob.glob('{0}*.gz'.format(local))]) log_size = get_size(log.filename) local_size = get_size(local) size = bes_unit_size(local_size + gz_size + log_size) log.block('Disk space used', '{0:>76.2f} {1}'.format(size['s'], size['u'])) log.time('End Time') log.free(os.linesep * 2) log.write(True) os.remove(script.name)
|
def mirror(args, log): """Mirror the directories.""" user = '' if args.anonymous else ' '.join(args.login) local, remote = os.path.normpath(args.local), os.path.normpath(args.remote) port = '-p {0}'.format(args.port) if args.port else '' include = ' --include-glob {0}'.format(args.inc_glob) if args.inc_glob else '' exclude = ' --exclude-glob {0}'.format(args.exc_glob) if args.exc_glob else '' url = 'http://code.joedicastro.com/lftp-mirror' msg = 'Connected to {1} as {2}{0}'.format(os.linesep, args.site, 'anonymous' if args.anonymous else args.login[0]) msg += 'Mirror {0} to {1}'.format(local if args.reverse else remote, remote if args.reverse else local) log.header(url, msg) log.time('Start time') notify('Mirroring with {0}...'.format(args.site), 'sync') if not os.path.exists(local): os.mkdir(local) log.list('Created new directory', local) os.chdir(os.path.join(local, os.pardir)) # create the script file to import with lftp scp_args = ('-vvv' + args.erase + args.newer + args.parallel + args.reverse + args.del_first + args.depth_first + args.no_empty_dir + args.no_recursion + args.dry_run + args.use_cache + args.del_source + args.missing + args.existing + args.loop + args.size + args.time + args.no_perms + args.no_umask + args.no_symlinks + args.suid + args.chown + args.dereference + exclude + include) with open('ftpscript', 'w') as script: lines = ('open {0}ftp://{1} {2}'.format(args.secure, args.site, port), 'user {0}'.format(user), 'mirror {0} {1} {2}'.format(scp_args, local if args.reverse else remote, remote if args.reverse else local), 'exit') script.write(os.linesep.join(lines)) # mirror cmd = ['lftp', '-d', '-f', script.name] sync = Popen(cmd, stdout=PIPE, stderr={True:STDOUT, False:None}[args.quiet]) # end mirroring log.list('lftp output', ''.join(sync.stdout.readlines())) # compress the dir and create a .gz file with date if not args.reverse and not args.no_compress: notify('Compressing folder...', 'info') log.list('Rotate compressed copies', compress(local)) # end compress gz_size = sum([get_size(gz) for gz in glob.glob('{0}*.gz'.format(local))]) log_size = get_size(log.filename) if os.path.exists(log.filename) else 0 local_size = get_size(local) size = bes_unit_size(local_size + gz_size + log_size) log.block('Disk space used', '{0:>76.2f} {1}'.format(size['s'], size['u'])) log.time('End Time') log.free(os.linesep * 2) log.write(True) os.remove(script.name)
| 473,706
|
def mirror(args, log): """Mirror the directories.""" user = '' if args.anonymous else ' '.join(args.login) local, remote = os.path.normpath(args.local), os.path.normpath(args.remote) port = '-p {0}'.format(args.port) if args.port else '' include = ' --include-glob {0}'.format(args.inc_glob) if args.inc_glob else '' exclude = ' --exclude-glob {0}'.format(args.exc_glob) if args.exc_glob else '' url = 'http://code.joedicastro.com/lftp-mirror' msg = 'Connected to {1} as {2}{0}'.format(os.linesep, args.site, 'anonymous' if args.anonymous else args.login[0]) msg += 'Mirror {0} to {1}'.format(local if args.reverse else remote, remote if args.reverse else local) log.header(url, msg) log.time('Start time') notify('Mirroring with {0}...'.format(args.site), 'sync') if not os.path.exists(local): os.mkdir(local) log.list('Created new directory', local) os.chdir(os.path.join(local, os.pardir)) # create the script file to import with lftp scp_args = ('-vvv' + args.erase + args.newer + args.parallel + args.reverse + args.del_first + args.depth_first + args.no_empty_dir + args.no_recursion + args.dry_run + args.use_cache + args.del_source + args.missing + args.existing + args.loop + args.size + args.time + args.no_perms + args.no_umask + args.no_symlinks + args.suid + args.chown + args.dereference + exclude + include) with open('ftpscript', 'w') as script: lines = ('open {0}ftp://{1} {2}'.format(args.secure, args.site, port), 'user {0}'.format(user), 'mirror {0} {1} {2}'.format(scp_args, local if args.reverse else remote, remote if args.reverse else local), 'exit') script.write(os.linesep.join(lines)) # mirror cmd = ['lftp', '-d', '-f', script.name] sync = Popen(cmd, stdout=PIPE, stderr={True:STDOUT, False:None}[args.quiet]) # end mirroring log.list('lftp output', ''.join(sync.stdout.readlines())) # compress the dir and create a .gz file with date if not args.reverse and not args.no_compress: notify('Compressing folder...', 'info') log.list('Rotate compressed copies', compress(local)) # end compress gz_size = sum([get_size(gz) for gz in glob.glob('{0}*.gz'.format(local))]) log_size = get_size(log.filename) local_size = get_size(local) size = bes_unit_size(local_size + gz_size + log_size) log.block('Disk space used', '{0:>76.2f} {1}'.format(size['s'], size['u'])) log.time('End Time') log.free(os.linesep * 2) log.write(True) os.remove(script.name)
|
def mirror(args, log): """Mirror the directories.""" user = '' if args.anonymous else ' '.join(args.login) local, remote = os.path.normpath(args.local), os.path.normpath(args.remote) port = '-p {0}'.format(args.port) if args.port else '' include = ' --include-glob {0}'.format(args.inc_glob) if args.inc_glob else '' exclude = ' --exclude-glob {0}'.format(args.exc_glob) if args.exc_glob else '' url = 'http://code.joedicastro.com/lftp-mirror' msg = 'Connected to {1} as {2}{0}'.format(os.linesep, args.site, 'anonymous' if args.anonymous else args.login[0]) msg += 'Mirror {0} to {1}'.format(local if args.reverse else remote, remote if args.reverse else local) log.header(url, msg) log.time('Start time') notify('Mirroring with {0}...'.format(args.site), 'sync') if not os.path.exists(local): os.mkdir(local) log.list('Created new directory', local) os.chdir(os.path.join(local, os.pardir)) # create the script file to import with lftp scp_args = ('-vvv' + args.erase + args.newer + args.parallel + args.reverse + args.del_first + args.depth_first + args.no_empty_dir + args.no_recursion + args.dry_run + args.use_cache + args.del_source + args.missing + args.existing + args.loop + args.size + args.time + args.no_perms + args.no_umask + args.no_symlinks + args.suid + args.chown + args.dereference + exclude + include) with open('ftpscript', 'w') as script: lines = ('open {0}ftp://{1} {2}'.format(args.secure, args.site, port), 'user {0}'.format(user), 'mirror {0} {1} {2}'.format(scp_args, local if args.reverse else remote, remote if args.reverse else local), 'exit') script.write(os.linesep.join(lines)) # mirror cmd = ['lftp', '-d', '-f', script.name] sync = Popen(cmd, stdout=PIPE, stderr={True:STDOUT, False:None}[args.quiet]) # end mirroring log.list('lftp output', ''.join(sync.stdout.readlines())) # compress the dir and create a .gz file with date if not args.reverse and not args.no_compress: notify('Compressing folder...', 'info') log.list('Rotate compressed copies', compress(local)) # end compress gz_size = sum([get_size(gz) for gz in glob.glob('{0}*.gz'.format(local))]) log_size = get_size(log.filename) local_size = get_size(local) size = best_unit_size(local_size + gz_size + log_size) log.block('Disk space used', '{0:>76.2f} {1}'.format(size['s'], size['u'])) log.time('End Time') log.free(os.linesep * 2) log.write(True) os.remove(script.name)
| 473,707
|
def arguments(): """Defines the command line arguments for the script.""" main_desc = ("Mirror a remote FTP directory into a local directory or vice " "versa through the lftp program") subs_desc = "Select a running mode from the following:" epilog = ("For detailed help for each mode, select a mode followed by help " "option, e.g.:{0}{0}%(prog)s shell -h").format(os.linesep) cron_use = "%(prog)s [-h]" shell_use = ("%(prog)s site remote local [options]{0}{0}By default " "downloads the changes from remote FTP directory to local " "directory.{0}To upload changes from local to remote FTP, use " "the 'r, --reverse' option").format(os.linesep) file_use = ("%(prog)s config_file [-h]{0}{0}The structure of the " "config file (a simple text file) is as follows:{0}{0}[section]" "{0}site = {{ftp server URL or IP}}{0}port = (ftp server port)" "{0}remote = {{remote directory}}{0}local = {{local directory}}" "{0}user = (ftp server username){0}password = (user password " "encoded in base64){0}options = (other options){0}{0}Section is" " a name that defines the mirror operation. Usually is the ftp " "server's name or directory' name. Useful for distinguish one " "mirror operation from others. Write one section for each " "mirror action with no limits in the number of sections.{0}{0}" "Values between curly brackets '{{}}' are required arguments " "and values between brackets '()' are optional arguments. If " "don't want optional arguments, left them blank. In case you do" " not specify a username and password, you must add the '-a' " "option which specifies that the connection is made with the " "anonymous user.{0}{0}The order of arguments doesn't matter, " "but all are needed.{0}{0}").format(os.linesep) parser = ArgumentParser(description=main_desc, epilog=epilog) subparsers = parser.add_subparsers(title="running modes", description=subs_desc) cron = subparsers.add_parser("cron", help="ideal to run as a scheduled task" ". Takes arguments from parameters defined " "within the script", usage=cron_use) cron.add_argument("cron", action="store_true", help=SUPPRESS, default=SUPPRESS) cron.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg = subparsers.add_parser("cfg", help="ideal for mirror multiple sites/" "directories. Imports the arguments from a " "config file", usage=file_use) cfg.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("cfg", action="store_true", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("config_file", help="config file to import arguments") shell = subparsers.add_parser("shell", help="usual mode, takes arguments " "from the command line ", usage=shell_use) shell.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("site", help="the ftp server (URL or IP)") shell.add_argument("remote", help="the remote directory") shell.add_argument("local", help="the local directory") auth = shell.add_mutually_exclusive_group(required=True) auth.add_argument("-l", "--login", dest="login", nargs=2, help="the ftp account's username and password", metavar=("user", "password")) auth.add_argument("-a", "--anon", action="store_true", dest="anonymous", help="set user as anonymous", default=False) shell.add_argument("-p", "--port", dest="port", default="", help="the ftp server port", metavar="port") shell.add_argument("-s", "--secure", action="store_const", const="s", dest="secure", default="", help="use the sftp protocol instead of ftp") shell.add_argument("-e", "--erase", action="store_const", const="e", dest="erase", default="", help="delete files not present at target site") shell.add_argument("-n", "--newer", action="store_const", const="n", dest="newer", default="", help="download only newer files") shell.add_argument("-P", "--parallel", action="store_const", const="P", dest="parallel", default="", help="download files in parallel") shell.add_argument("-r", "--reverse", action="store_const", const="R", dest="reverse", default="", help="reverse, upload files from local to remote") shell.add_argument("--delete-first", action="store_const", const=" --delete-first", dest="del_first", default="", help="delete old files before transferring new ones") shell.add_argument("--depth-first", action="store_const", const=" --depth-first", dest="depth_first", default="", help="descend into subdirectories, before transfer files") shell.add_argument("--no-empty-dirs", action="store_const", const=" --no-empty-dirs", dest="no_empty_dir", default="", help="don't create empty dirs (needs --depth-first)") shell.add_argument("--no-recursion", action="store_const", const=" --no-recursion", dest="no_recursion", default="", help="don't go to subdirectories") shell.add_argument("--dry-run", action="store_const", const=" --dry-run", dest="dry_run", default="", help="simulation, don't execute anything. Writes to log") shell.add_argument("--use-cache", action="store_const", const=" --use-cache", dest="use_cache", default="", help="use cached directory listings") shell.add_argument("--del-source", action="store_const", const=" --Remove-source-files", dest="del_source", default="", help="remove files (no dirs) after transfer (Caution!)") shell.add_argument("--only-missing", action="store_const", const=" --only-missing", dest="missing", default="", help="download only missing files") shell.add_argument("--only-existing", action="store_const", const=" --only-existing", dest="existing", default="", help="download only files already existing at target") shell.add_argument("--loop", action="store_const", const=" --loop", dest="loop", default="", help="Loop until no changes found") shell.add_argument("--ignore-size", action="store_const", const=" --ignore-size", dest="size", default="", help="ignore size when deciding whether to download") shell.add_argument("--ignore-time", action="store_const", const=" --ignore-time", dest="time", default="", help="ignore time when deciding whether to download") shell.add_argument("--no-perms", action="store_const", const=" --no-perms", dest="no_perms", default="", help="don't set file permissions") shell.add_argument("--no-umask", action="store_const", const=" --no-umask", dest="no_umask", default="", help="don't apply umask to file modes") shell.add_argument("--no-symlinks", action="store_const", const=" --no-symlinks", dest="no_symlinks", default="", help="don't create symbolic links") shell.add_argument("--allow-suid", action="store_const", const=" --allow-suid", dest="suid", default="", help="set suid/sgid bits according to remote site") shell.add_argument("--allow-chown", action="store_const", const=" --allow-chown", dest="chown", default="", help="try to set owner and group on files") shell.add_argument("--dereference", action="store_const", const=" --dereference", dest="dereference", default="", help="download symbolic links as files") shell.add_argument("--exclude-glob", dest="exc_glob", default="", metavar="GP", help="exclude matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("--include-glob", dest="inc_glob", default="", metavar="GP", help="include matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("-q", "--quiet", action="store_true", dest="quiet", help="the detailed shell process is no " "displayed, but is added to the log", default=False) shell.add_argument("--no-compress", action="store_true", dest="no_compress", help="don't create daily archive " "files", default=False) shell.add_argument("--no-email", action="store_true", dest="no_email", help="no sends email with the log", default=False) shell.add_argument("--smtp_server", dest="smtp_server", default="localhost", metavar="server", help="set a smtp server") shell.add_argument("--smtp_user", dest="smtp_user", default="", metavar="user", help="the smtp server username") shell.add_argument("--smtp_pass", dest="smtp_pass", default="", metavar="password", help="the smtp server password") shell.add_argument("--from_addr", dest="from_addr", default="", metavar="email", help="sender's email address") shell.add_argument("--to_addrs", dest="to_addrs", default="", nargs='+', metavar="email", help="a list of receiver(s)' email address(es)") parser.add_argument("-v", "--version", action="version", version="%(prog)s {0}".format(__version__), help="show program's version number and exit") return parser
|
def arguments(): """Defines the command line arguments for the script.""" main_desc = ("Mirror a remote FTP directory into a local directory or vice " "versa through the lftp program") subs_desc = "Select a running mode from the following:" epilog = ("For detailed help for each mode, select a mode followed by help " "option, e.g.:{0}{0}%(prog)s shell -h").format(os.linesep) cron_use = "%(prog)s [-h]" shell_use = ("%(prog)s site remote local [options]{0}{0}By default " "downloads the changes from remote FTP directory to local " "directory.{0}To upload changes from local to remote FTP, use " "the 'r, --reverse' option").format(os.linesep) file_use = ("%(prog)s config_file [-h]{0}{0}The structure of the " "config file (a simple text file) is as follows:{0}{0}[section]" "{0}site = {{ftp server URL or IP}}{0}port = (ftp server port)" "{0}remote = {{remote directory}}{0}local = {{local directory}}" "{0}user = (ftp server username){0}password = (user password " "encoded in base64){0}options = (other options){0}{0}Section is" " a name that defines the mirror operation. Usually is the ftp " "server's name or directory' name. Useful for distinguish one " "mirror operation from others. Write one section for each " "mirror action with no limits in the number of sections.{0}{0}" "Values between curly brackets '{{}}' are required arguments " "and values between brackets '()' are optional arguments. If " "don't want optional arguments, left them blank. In case you do" " not specify a username and password, you must add the '-a' " "option which specifies that the connection is made with the " "anonymous user.{0}{0}The order of arguments doesn't matter, " "but all are needed.{0}{0}").format(os.linesep) parser = ArgumentParser(description=main_desc, epilog=epilog) subparsers = parser.add_subparsers(title="running modes", description=subs_desc) cron = subparsers.add_parser("cron", help="ideal to run as a scheduled task" ". Takes arguments from parameters defined " "within the script", usage=cron_use) cron.add_argument("cron", action="store_true", help=SUPPRESS, default=SUPPRESS) cron.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg = subparsers.add_parser("cfg", help="ideal for mirror multiple sites/" "directories. Imports the arguments from a " "config file", usage=file_use) cfg.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("cfg", action="store_true", help=SUPPRESS, default=SUPPRESS) cfg.add_argument("config_file", help="config file to import arguments") shell = subparsers.add_parser("shell", help="usual mode, takes arguments " "from the command line ", usage=shell_use) shell.add_argument("cron", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("cfg", action="store_false", help=SUPPRESS, default=SUPPRESS) shell.add_argument("site", help="the ftp server (URL or IP)") shell.add_argument("remote", help="the remote directory") shell.add_argument("local", help="the local directory") auth = shell.add_mutually_exclusive_group(required=True) auth.add_argument("-l", "--login", dest="login", nargs=2, help="the ftp account's username and password", metavar=("user", "password")) auth.add_argument("-a", "--anon", action="store_true", dest="anonymous", help="set user as anonymous", default=False) shell.add_argument("-p", "--port", dest="port", default="", help="the ftp server port", metavar="port") shell.add_argument("-s", "--secure", action="store_const", const="s", dest="secure", default="", help="use the sftp protocol instead of ftp") shell.add_argument("-e", "--erase", action="store_const", const="e", dest="erase", default="", help="delete files not present at target site") shell.add_argument("-n", "--newer", action="store_const", const="n", dest="newer", default="", help="download only newer files") shell.add_argument("-P", "--parallel", action="store_const", const="P", dest="parallel", default="", help="download files in parallel") shell.add_argument("-r", "--reverse", action="store_const", const="R", dest="reverse", default="", help="reverse, upload files from local to remote") shell.add_argument("--delete-first", action="store_const", const=" --delete-first", dest="del_first", default="", help="delete old files before transferring new ones") shell.add_argument("--depth-first", action="store_const", const=" --depth-first", dest="depth_first", default="", help="descend into subdirectories, before transfer files") shell.add_argument("--no-empty-dirs", action="store_const", const=" --no-empty-dirs", dest="no_empty_dir", default="", help="don't create empty dirs (needs --depth-first)") shell.add_argument("--no-recursion", action="store_const", const=" --no-recursion", dest="no_recursion", default="", help="don't go to subdirectories") shell.add_argument("--dry-run", action="store_const", const=" --dry-run", dest="dry_run", default="", help="simulation, don't execute anything. Writes to log") shell.add_argument("--use-cache", action="store_const", const=" --use-cache", dest="use_cache", default="", help="use cached directory listings") shell.add_argument("--del-source", action="store_const", const=" --Remove-source-files", dest="del_source", default="", help="remove files (no dirs) after transfer (Caution!)") shell.add_argument("--only-missing", action="store_const", const=" --only-missing", dest="missing", default="", help="download only missing files") shell.add_argument("--only-existing", action="store_const", const=" --only-existing", dest="existing", default="", help="download only files already existing at target") shell.add_argument("--loop", action="store_const", const=" --loop", dest="loop", default="", help="loop until no changes found") shell.add_argument("--ignore-size", action="store_const", const=" --ignore-size", dest="size", default="", help="ignore size when deciding whether to download") shell.add_argument("--ignore-time", action="store_const", const=" --ignore-time", dest="time", default="", help="ignore time when deciding whether to download") shell.add_argument("--no-perms", action="store_const", const=" --no-perms", dest="no_perms", default="", help="don't set file permissions") shell.add_argument("--no-umask", action="store_const", const=" --no-umask", dest="no_umask", default="", help="don't apply umask to file modes") shell.add_argument("--no-symlinks", action="store_const", const=" --no-symlinks", dest="no_symlinks", default="", help="don't create symbolic links") shell.add_argument("--allow-suid", action="store_const", const=" --allow-suid", dest="suid", default="", help="set suid/sgid bits according to remote site") shell.add_argument("--allow-chown", action="store_const", const=" --allow-chown", dest="chown", default="", help="try to set owner and group on files") shell.add_argument("--dereference", action="store_const", const=" --dereference", dest="dereference", default="", help="download symbolic links as files") shell.add_argument("--exclude-glob", dest="exc_glob", default="", metavar="GP", help="exclude matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("--include-glob", dest="inc_glob", default="", metavar="GP", help="include matching files. GP is a glob pattern, e.g." " '*.zip'") shell.add_argument("-q", "--quiet", action="store_true", dest="quiet", help="the detailed shell process is no " "displayed, but is added to the log", default=False) shell.add_argument("--no-compress", action="store_true", dest="no_compress", help="don't create daily archive " "files", default=False) shell.add_argument("--no-email", action="store_true", dest="no_email", help="no sends email with the log", default=False) shell.add_argument("--smtp_server", dest="smtp_server", default="localhost", metavar="server", help="set a smtp server") shell.add_argument("--smtp_user", dest="smtp_user", default="", metavar="user", help="the smtp server username") shell.add_argument("--smtp_pass", dest="smtp_pass", default="", metavar="password", help="the smtp server password") shell.add_argument("--from_addr", dest="from_addr", default="", metavar="email", help="sender's email address") shell.add_argument("--to_addrs", dest="to_addrs", default="", nargs='+', metavar="email", help="a list of receiver(s)' email address(es)") parser.add_argument("-v", "--version", action="version", version="%(prog)s {0}".format(__version__), help="show program's version number and exit") return parser
| 473,708
|
def send_body(self, DATA, code = None, msg = None, desc = None, ctype='application/octet-stream', headers={}): """ send a body in one part """ log.debug("Use send_body method")
|
def send_body(self, DATA, code = None, msg = None, desc = None, ctype='application/octet-stream', headers={}): """ send a body in one part """ log.debug("Use send_body method")
| 473,709
|
def send_body(self, DATA, code = None, msg = None, desc = None, ctype='application/octet-stream', headers={}): """ send a body in one part """ log.debug("Use send_body method")
|
def send_body(self, DATA, code = None, msg = None, desc = None, ctype='application/octet-stream', headers={}): """ send a body in one part """ log.debug("Use send_body method")
| 473,710
|
def send_body_chunks(self, DATA, code, msg, desc, ctype='text/xml; encoding="utf-8"'): """ send a body in chunks """
|
def send_body_chunks(self, DATA, code, msg=None, desc=None, ctype='text/xml"', headers={}): """ send a body in chunks """
| 473,711
|
def send_body_chunks(self, DATA, code, msg, desc, ctype='text/xml; encoding="utf-8"'): """ send a body in chunks """
|
def send_body_chunks(self, DATA, code, msg, desc, ctype='text/xml; encoding="utf-8"'): """ send a body in chunks """
| 473,712
|
def do_OPTIONS(self): """return the list of capabilities """
|
def do_OPTIONS(self): """return the list of capabilities """
| 473,713
|
def _HEAD_GET(self, with_body=False): """ Returns headers and body for given resource """
|
def _HEAD_GET(self, with_body=False): """ Returns headers and body for given resource """
| 473,714
|
def get_data(self,uri, range = None): """ return the content of an object """ path=self.uri2local(uri) if os.path.exists(path): if os.path.isfile(path): file_size = os.path.getsize(path) if range == None: fp=open(path,"r") log.info('Serving content of %s' % uri) return Resource(fp, file_size) else: if range[0] == '': range[0] = 0 else: range[0] = int(range[0])
|
def get_data(self,uri, range = None): """ return the content of an object """ path=self.uri2local(uri) if os.path.exists(path): if os.path.isfile(path): file_size = os.path.getsize(path) if range == None: fp=open(path,"r") log.info('Serving content of %s' % uri) return Resource(fp, file_size) else: if range[0] == '': range[0] = 0 else: range[0] = int(range[0])
| 473,715
|
def edit_entry(self, **kwargs): """ In this call we handle a form which contains one entry. This entry has a text and time field which we expect to change. """ plone = self.getCommandSet("plone") core = self.getCommandSet("core") tracker = get_tracker(self.context) text = self.request.get('text') if not text: message = _(u'msg_empty_text', default=u'Empty text, this is not allowed') plone.issuePortalMessage(message, msgtype="error") return time = self.request.get('time') uid = self.request.get('uid') idx = int(self.request.get('entry_number'))
|
def edit_entry(self, **kwargs): """ In this call we handle a form which contains one entry. This entry has a text and time field which we expect to change. """ plone = self.getCommandSet("plone") core = self.getCommandSet("core") tracker = get_tracker(self.context) text = self.request.get('text') if not text: message = _(u'msg_empty_text', default=u'Empty text, this is not allowed') plone.issuePortalMessage(message, msgtype="error") return time = self.request.get('time') uid = self.request.get('uid') idx = int(self.request.get('entry_number'))
| 473,716
|
def add_entry(tracker, task, text): current_time = mx.DateTime.now() time = current_time - tracker.starttime rounded_time = mx.DateTime.DateTimeDelta( time.day, time.hour, math.ceil(time.minutes)) task.entries.append(Entry(text, rounded_time)) # Reset the timer's start time tracker.starttime = current_time
|
def add_entry(tracker, task, text): current_time = mx.DateTime.now() time = current_time - tracker.starttime rounded_time = round_time_to_minutes(time) task.entries.append(Entry(text, rounded_time)) # Reset the timer's start time tracker.starttime = current_time
| 473,717
|
def handleException(self, object, request, exc_info, retry_allowed=True): orig = removeAllProxies(object) oldHandleException(self, object, request, exc_info, retry_allowed=retry_allowed) if type(orig) is MethodType: notify(AfterCallEvent(orig.im_self, request)) else: notify(AfterCallEvent(orig, request))
|
def handleException(self, object, request, exc_info, retry_allowed=True): orig = removeAllProxies(object) oldHandleException(self, object, request, exc_info, retry_allowed=retry_allowed) if type(orig) is MethodType: notify(AfterCallEvent(orig.im_self, request)) else: notify(AfterCallEvent(orig, request))
| 473,718
|
def generate(self): self.uid = md5.md5(time.ctime()).hexdigest()
|
def generate(self): self.uid = md5.md5(time.ctime()).hexdigest()
| 473,719
|
def handleException(self, object, request, exc_info, retry_allowed=True): orig = removeAllProxies(object) oldHandleException(self, object, request, exc_info, retry_allowed=retry_allowed) if type(orig) is MethodType: notify(AfterCallEvent(orig.im_self, request)) else: notify(AfterCallEvent(orig, request))
|
def handleException(self, object, request, exc_info, retry_allowed=True): orig = removeAllProxies(object) oldHandleException(self, object, request, exc_info, retry_allowed=retry_allowed) if type(orig) is MethodType: notify(AfterExceptionCallEvent(orig.im_self, request)) else: notify(AfterCallEvent(orig, request))
| 473,720
|
def handleException(self, object, request, exc_info, retry_allowed=True): orig = removeAllProxies(object) oldHandleException(self, object, request, exc_info, retry_allowed=retry_allowed) if type(orig) is MethodType: notify(AfterCallEvent(orig.im_self, request)) else: notify(AfterCallEvent(orig, request))
|
def handleException(self, object, request, exc_info, retry_allowed=True): orig = removeAllProxies(object) oldHandleException(self, object, request, exc_info, retry_allowed=retry_allowed) if type(orig) is MethodType: notify(AfterCallEvent(orig.im_self, request)) else: notify(AfterExceptionCallEvent(orig, request))
| 473,721
|
def handleException(self, object, request, exc_info, retry_allowed=True): orig = removeAllProxies(object) oldHandleException(self, object, request, exc_info, retry_allowed=retry_allowed) if type(orig) is MethodType: notify(AfterCallEvent(orig.im_self, request)) else: notify(AfterCallEvent(orig, request))
|
defzopepublication.ZopePublication.handleException = handleException handleException(self,zopepublication.ZopePublication.handleException = handleException object,zopepublication.ZopePublication.handleException = handleException request,zopepublication.ZopePublication.handleException = handleException exc_info,zopepublication.ZopePublication.handleException = handleException retry_allowed=True):zopepublication.ZopePublication.handleException = handleException origzopepublication.ZopePublication.handleException = handleException =zopepublication.ZopePublication.handleException = handleException removeAllProxies(object)zopepublication.ZopePublication.handleException = handleException oldHandleException(self,zopepublication.ZopePublication.handleException = handleException object,zopepublication.ZopePublication.handleException = handleException request,zopepublication.ZopePublication.handleException = handleException exc_info,zopepublication.ZopePublication.handleException = handleException retry_allowed=retry_allowed)zopepublication.ZopePublication.handleException = handleException ifzopepublication.ZopePublication.handleException = handleException type(orig)zopepublication.ZopePublication.handleException = handleException iszopepublication.ZopePublication.handleException = handleException MethodType:zopepublication.ZopePublication.handleException = handleException notify(AfterCallEvent(orig.im_self,zopepublication.ZopePublication.handleException = handleException request))zopepublication.ZopePublication.handleException = handleException else:zopepublication.ZopePublication.handleException = handleException notify(AfterCallEvent(orig,zopepublication.ZopePublication.handleException = handleException request))zopepublication.ZopePublication.handleException = handleException
| 473,722
|
def generate(self): return md5.md5(datetime.datetime.now().isoformat()).hexdigest()
|
def generate(self): return md5.md5(datetime.datetime.now().isoformat()).hexdigest()
| 473,723
|
def handleException(self, object, request, exc_info, retry_allowed=True): super(BrowserPublication, self).handleException( object, request, exc_info, retry_allowed)
|
def handleException(self, object, request, exc_info, retry_allowed=True): super(BrowserPublication, self).handleException( object, request, exc_info, retry_allowed)
| 473,724
|
def run(self, params, args):
|
def run(self, params, args):
| 473,725
|
def run(self, params, args):
|
def run(self, params, args):
| 473,726
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
| 473,727
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
| 473,728
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
| 473,729
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
| 473,730
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
| 473,731
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
|
def deleteRule(self, table, extrawhere, service, network, outnetwork, chain, action, protocol):
| 473,732
|
def run(self, params, args): (state, key) = self.fillParams([ ('state', ), ('key', ) ]) if not len(args): self.abort('must supply at least one host')
|
def run(self, params, args): (switch, key) = self.fillParams([ ('switch', ), ('key', ) ]) if not len(args): self.abort('must supply at least one host')
| 473,733
|
def run(self, params, args): (state, key) = self.fillParams([ ('state', ), ('key', ) ]) if not len(args): self.abort('must supply at least one host')
|
def run(self, params, args): (state, key) = self.fillParams([ ('state', ), ('key', ) ]) if not len(args): self.abort('must supply at least one host')
| 473,734
|
def run(self, params, args): (state, key) = self.fillParams([ ('state', ), ('key', ) ]) if not len(args): self.abort('must supply at least one host')
|
def run(self, params, args): (state, key) = self.fillParams([ ('state', ), ('key', ) ]) if not len(args): self.abort('must supply at least one host')
| 473,735
|
def run(self, params, args):
|
def run(self, params, args):
| 473,736
|
def bootloaderSetupChoices(anaconda): if anaconda.dir == DISPATCH_BACK: return # FIXME: this is a hack... if flags.livecd: return if anaconda.id.ksdata: anaconda.id.bootloader.updateDriveList(anaconda.id.ksdata.bootloader["driveorder"]) else: anaconda.id.bootloader.updateDriveList()
|
def bootloaderSetupChoices(anaconda): if anaconda.dir == DISPATCH_BACK: return # FIXME: this is a hack... if flags.livecd: return if anaconda.id.ksdata: anaconda.id.bootloader.updateDriveList(anaconda.id.ksdata.bootloader["driveorder"]) else: anaconda.id.bootloader.updateDriveList()
| 473,737
|
def bootloaderSetupChoices(anaconda): if anaconda.dir == DISPATCH_BACK: return # FIXME: this is a hack... if flags.livecd: return if anaconda.id.ksdata: anaconda.id.bootloader.updateDriveList(anaconda.id.ksdata.bootloader["driveorder"]) else: anaconda.id.bootloader.updateDriveList()
|
def bootloaderSetupChoices(anaconda): if anaconda.dir == DISPATCH_BACK: return # FIXME: this is a hack... if flags.livecd: return if anaconda.id.ksdata: anaconda.id.bootloader.updateDriveList(anaconda.id.ksdata.bootloader["driveorder"]) else: anaconda.id.bootloader.updateDriveList()
| 473,738
|
def bootloaderSetupChoices(anaconda): if anaconda.dir == DISPATCH_BACK: return # FIXME: this is a hack... if flags.livecd: return if anaconda.id.ksdata: anaconda.id.bootloader.updateDriveList(anaconda.id.ksdata.bootloader["driveorder"]) else: anaconda.id.bootloader.updateDriveList()
|
def bootloaderSetupChoices(anaconda): if anaconda.dir == DISPATCH_BACK: return # FIXME: this is a hack... if flags.livecd: return if anaconda.id.ksdata: anaconda.id.bootloader.updateDriveList(anaconda.id.ksdata.bootloader["driveorder"]) else: anaconda.id.bootloader.updateDriveList()
| 473,739
|
def bootloaderSetupChoices(anaconda): if anaconda.dir == DISPATCH_BACK: return # FIXME: this is a hack... if flags.livecd: return if anaconda.id.ksdata: anaconda.id.bootloader.updateDriveList(anaconda.id.ksdata.bootloader["driveorder"]) else: anaconda.id.bootloader.updateDriveList()
|
def bootloaderSetupChoices(anaconda): if anaconda.dir == DISPATCH_BACK: return # FIXME: this is a hack... if flags.livecd: return if anaconda.id.ksdata: anaconda.id.bootloader.updateDriveList(anaconda.id.ksdata.bootloader["driveorder"]) else: anaconda.id.bootloader.updateDriveList()
| 473,740
|
def dosync(): isys.sync() isys.sync() isys.sync()
|
def dosync(): isys.sync() isys.sync() isys.sync()
| 473,741
|
def dosync(): isys.sync() isys.sync() isys.sync()
|
def dosync(): isys.sync() isys.sync() isys.sync()
| 473,742
|
def rectifyLuksName(anaconda, name): if name is not None and name.startswith('mapper/luks-'): try: newname = anaconda.id.partitions.encryptedDevices.get(name[12:]) if newname is None: for luksdev in anaconda.id.partitions.encryptedDevices.values(): if os.path.basename(luksdev.getDevice(encrypted=1)) == name[12:]: newname = luksdev break name = newname.getDevice() except: pass return name
|
def rectifyLuksName(anaconda, name): if name is not None and name.startswith('mapper/luks-'): try: newname = anaconda.id.partitions.encryptedDevices.get(name[12:]) if newname is None: for luksdev in anaconda.id.partitions.encryptedDevices.values(): if os.path.basename(luksdev.getDevice(encrypted=1)) == name[12:]: newname = luksdev break name = newname.getDevice() except: pass return name
| 473,743
|
def rectifyLuksName(anaconda, name): if name is not None and name.startswith('mapper/luks-'): try: newname = anaconda.id.partitions.encryptedDevices.get(name[12:]) if newname is None: for luksdev in anaconda.id.partitions.encryptedDevices.values(): if os.path.basename(luksdev.getDevice(encrypted=1)) == name[12:]: newname = luksdev break name = newname.getDevice() except: pass return name
|
def rectifyLuksName(anaconda, name): if name is not None and name.startswith('mapper/luks-'): try: newname = anaconda.id.partitions.encryptedDevices.get(name[12:]) if newname is None: for luksdev in anaconda.id.partitions.encryptedDevices.values(): if os.path.basename(luksdev.getDevice(encrypted=1)) == name[12:]: newname = luksdev break name = newname.getDevice() except: pass return name
| 473,744
|
def getBootloader(): if not flags.livecd: return booty.getBootloader() else: return bootloaderInfo.isolinuxBootloaderInfo()
|
def getBootloader(): if not flags.livecd: return booty.getBootloader() else: return bootloaderInfo.isolinuxBootloaderInfo()
| 473,745
|
def hostlocal(self, name, dnszone): "Appends any manually defined hosts to domain file" filename = '/var/named/%s.domain.local' % name s = '' if os.path.isfile(filename): s += "; import from %s\n" % filename file = open(filename, 'r') s += file.read() file.close() s += '\n' return s
|
def hostlocal(self, name, dnszone): "Appends any manually defined hosts to domain file" filename = '/var/named/%s.domain.local' % name s = '' if os.path.isfile(filename): s += "\n;Imported from %s\n\n" % filename file = open(filename, 'r') s += file.read() file.close() s += '\n' return s
| 473,746
|
def hostlocal(self, name, dnszone): "Appends any manually defined hosts to domain file" filename = '/var/named/%s.domain.local' % name s = '' if os.path.isfile(filename): s += "; import from %s\n" % filename file = open(filename, 'r') s += file.read() file.close() s += '\n' return s
|
def hostlocal(self, name, dnszone): "Appends any manually defined hosts to domain file" filename = '/var/named/%s.domain.local' % name s = '' if os.path.isfile(filename): s += "; import from %s\n" % filename file = open(filename, 'r') s += file.read() file.close() else: s += "</file>\n" s += '<file name="%s" perms="0644">\n' % filename s += ';Extra host mappings go here. Example\n' s += ';myhost A 10.1.1.1\n' return s
| 473,747
|
def writeGrub(self, instRoot, fsset, bl, langs, kernelList, chainList, defaultDev, justConfigFile): if len(kernelList) < 1: return "" images = bl.images.getImages() rootDev = fsset.getEntryByMountPoint("/").device.getDevice()
|
def writeGrub(self, instRoot, fsset, bl, langs, kernelList, chainList, defaultDev, justConfigFile): if len(kernelList) < 1: return "" images = bl.images.getImages() rootDev = fsset.getEntryByMountPoint("/").device.getDevice()
| 473,748
|
def run_sunos(self, host): # Ignore IPMI devices and get all the other configured # interfaces self.db.execute("select networks.ip, networks.device " +\ "from networks, nodes where " +\ "nodes.name='%s' " % (host) +\ "and networks.device!='ipmi' " +\ "and networks.node=nodes.id")
|
def run_sunos(self, host): # Ignore IPMI devices and get all the other configured # interfaces self.db.execute("select networks.ip, networks.device, " +\ "subnets.netmask from networks, nodes, " +\ "subnets where nodes.name='%s' " % (host)+\ "and networks.subnet=subnets.id " +\ "and networks.device!='ipmi' " +\ "and networks.node=nodes.id")
| 473,749
|
def run_sunos(self, host): # Ignore IPMI devices and get all the other configured # interfaces self.db.execute("select networks.ip, networks.device " +\ "from networks, nodes where " +\ "nodes.name='%s' " % (host) +\ "and networks.device!='ipmi' " +\ "and networks.node=nodes.id")
|
def run_sunos(self, host): # Ignore IPMI devices and get all the other configured # interfaces self.db.execute("select networks.ip, networks.device " +\ "from networks, nodes where " +\ "nodes.name='%s' " % (host) +\ "and networks.device!='ipmi' " +\ "and networks.node=nodes.id")
| 473,750
|
def run_sunos(self, host): # Ignore IPMI devices and get all the other configured # interfaces self.db.execute("select networks.ip, networks.device " +\ "from networks, nodes where " +\ "nodes.name='%s' " % (host) +\ "and networks.device!='ipmi' " +\ "and networks.node=nodes.id")
|
def run_sunos(self, host): # Ignore IPMI devices and get all the other configured # interfaces self.db.execute("select networks.ip, networks.device " +\ "from networks, nodes where " +\ "nodes.name='%s' " % (host) +\ "and networks.device!='ipmi' " +\ "and networks.node=nodes.id")
| 473,751
|
def write_host_file_sunos(self, ip, device): s = '<file name="/etc/hostname.%s">\n' % device s += "%s\n" % ip s += '</file>\n' self.addText(s)
|
def write_host_file_sunos(self, ip, netmask, device): s = '<file name="/etc/hostname.%s">\n' % device s += "%s\n" % ip s += '</file>\n' self.addText(s)
| 473,752
|
def write_host_file_sunos(self, ip, device): s = '<file name="/etc/hostname.%s">\n' % device s += "%s\n" % ip s += '</file>\n' self.addText(s)
|
def write_host_file_sunos(self, ip, device): s = '<file name="/etc/hostname.%s">\n' % device s += "%s netmask %s\n" % (ip, netmask) s += '</file>\n' self.addText(s)
| 473,753
|
def getOSNames(self, args=None): """Returns a list of OS names. For each arg in the ARGS list normalize the name to one of either 'linux' or 'sunos' as they are the only supported OSes. If the ARGS list is empty return a list of all supported OS names. """
|
def getOSNames(self, args=None): """Returns a list of OS names. For each arg in the ARGS list normalize the name to one of either 'linux' or 'sunos' as they are the only supported OSes. If the ARGS list is empty return a list of all supported OS names. """
| 473,754
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
| 473,755
|
def kill(self): os.kill(self.p.pid, 9)
|
def kill(self): os.kill(self.p.pid, 9)
| 473,756
|
def kill(self): os.kill(self.p.pid, 9)
|
def kill(self): os.kill(self.p.pid, 9)
| 473,757
|
def kill(self): os.kill(self.p.pid, 9)
|
def kill(self): os.kill(self.p.pid, 9)
| 473,758
|
def kill(self): os.kill(self.p.pid, 9)
|
def kill(self): os.kill(self.p.pid, 9)
| 473,759
|
def kill(self): os.kill(self.p.pid, 9)
|
def kill(self): os.kill(self.p.pid, 9)
| 473,760
|
def kill(self): os.kill(self.p.pid, 9)
|
def kill(self): os.kill(self.p.pid, 9)
| 473,761
|
def kill(self): os.kill(self.p.pid, 9)
|
def kill(self): os.kill(self.p.pid, 9)
| 473,762
|
def kill(self): os.kill(self.p.pid, 9)
|
def kill(self): os.kill(self.p.pid, 9)
| 473,763
|
def run_linux(self, host): self.db.execute("""select distinctrow net.mac, net.ip, net.device, if(net.subnet, s.netmask, NULL), net.vlanid, net.subnet, net.module, s.mtu, net.options, net.channel from networks net, nodes n, subnets s where net.node = n.id and if(net.subnet, net.subnet = s.id, true) and n.name = "%s" order by net.id""" % (host))
|
def run_linux(self, host): self.db.execute("""select distinctrow net.mac, net.ip, net.device, if(net.subnet, s.netmask, NULL), net.vlanid, net.subnet, net.module, s.mtu, net.options, net.channel from networks net, nodes n, subnets s where net.node = n.id and if(net.subnet, net.subnet = s.id, true) and n.name = "%s" order by net.id""" % (host))
| 473,764
|
def run(self, params, args): hosts = self.getHostnames(args, managed_only=1)
|
def run(self, params, args): hosts = self.getHostnames(args, managed_only=1)
| 473,765
|
def run(self, params, args): hosts = self.getHostnames(args, managed_only=1)
|
def run(self, params, args): hosts = self.getHostnames(args, managed_only=1)
| 473,766
|
def run(self, params, args): hosts = self.getHostnames(args, managed_only=1)
|
def run(self, params, args): hosts = self.getHostnames(args, managed_only=1)
| 473,767
|
def nodeup(self, host): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(2) try: # # this catches the case when the host is down # and/or there is no ssh daemon running # sock.connect((host, 22))
|
def nodeup(self, host): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(2.0) try: # # this catches the case when the host is down # and/or there is no ssh daemon running # sock.connect((host, 22))
| 473,768
|
def nodeup(self, host): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(2) try: # # this catches the case when the host is down # and/or there is no ssh daemon running # sock.connect((host, 22))
|
def nodeup(self, host): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(2) try: # # this catches the case when the host is down # and/or there is no ssh daemon running # sock.connect((host, 22))
| 473,769
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
| 473,770
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
| 473,771
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
| 473,772
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
| 473,773
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
|
def run(self, params, args): (args, command) = self.fillPositionalArgs(('command', ))
| 473,774
|
def printHost(self, name, hostname, mac, ip): self.addOutput('', '\t\thost %s {' % name) if mac: self.addOutput('', '\t\t\thardware ethernet %s;' % mac)
|
def printHost(self, name, hostname, mac, ip): self.addOutput('', '\t\thost %s {' % name) if mac: self.addOutput('', '\t\t\thardware ethernet %s;' % mac)
| 473,775
|
def run(self, url, sig):
|
def run(self, url, sig):
| 473,776
|
def run(self, url, sig):
|
def run(self, url, sig):
| 473,777
|
def getHostnames(self, names=None, managed_only=0): """Expands the given list of names to valid cluster hostnames. A name can be a hostname, IP address, our group (membership name), or a MAC address. Any combination of these is valid. If the names list is empty a list of all hosts in the cluster is returned. The following groups are recognized: rackN - All non-frontend host in rack N appliancename - All appliances of a given type (e.g. compute) select ... - an SQL statement that returns a list of hosts
|
def getHostnames(self, names=None, managed_only=0): """Expands the given list of names to valid cluster hostnames. A name can be a hostname, IP address, our group (membership name), or a MAC address. Any combination of these is valid. If the names list is empty a list of all hosts in the cluster is returned. The following groups are recognized: rackN - All non-frontend host in rack N appliancename - All appliances of a given type (e.g. compute) select ... - an SQL statement that returns a list of hosts
| 473,778
|
def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except: strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except: strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
| 473,779
|
def __init__(self, *args): this = apply(_quickfix.new_IntArray, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_IntArray(*args) try: self.this.append(this) except: self.this = this
| 473,780
|
def __getitem__(*args): return apply(_quickfix.IntArray___getitem__, args)
|
def __getitem__(*args): return apply(_quickfix.IntArray___getitem__, args)
| 473,781
|
def __init__(self, *args): this = apply(_quickfix.new_Exception, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_Exception(*args) try: self.this.append(this) except: self.this = this
| 473,782
|
def __str__(*args): return apply(_quickfix.Exception___str__, args)
|
def __str__(*args): return apply(_quickfix.Exception___str__, args)
| 473,783
|
def __init__(self, *args): this = apply(_quickfix.new_DataDictionaryNotFound, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_DataDictionaryNotFound(*args) try: self.this.append(this) except: self.this = this
| 473,784
|
def __init__(self, *args): this = apply(_quickfix.new_FieldNotFound, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_FieldNotFound(*args) try: self.this.append(this) except: self.this = this
| 473,785
|
def __init__(self, *args): this = apply(_quickfix.new_FieldConvertError, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_FieldConvertError(*args) try: self.this.append(this) except: self.this = this
| 473,786
|
def __init__(self, *args): this = apply(_quickfix.new_MessageParseError, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_MessageParseError(*args) try: self.this.append(this) except: self.this = this
| 473,787
|
def __init__(self, *args): this = apply(_quickfix.new_InvalidMessage, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_InvalidMessage(*args) try: self.this.append(this) except: self.this = this
| 473,788
|
def __init__(self, *args): this = apply(_quickfix.new_ConfigError, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_ConfigError(*args) try: self.this.append(this) except: self.this = this
| 473,789
|
def __init__(self, *args): this = apply(_quickfix.new_RuntimeError, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_RuntimeError(*args) try: self.this.append(this) except: self.this = this
| 473,790
|
def __init__(self, *args): this = apply(_quickfix.new_InvalidTagNumber, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_InvalidTagNumber(*args) try: self.this.append(this) except: self.this = this
| 473,791
|
def __init__(self, *args): this = apply(_quickfix.new_RequiredTagMissing, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_RequiredTagMissing(*args) try: self.this.append(this) except: self.this = this
| 473,792
|
def __init__(self, *args): this = apply(_quickfix.new_TagNotDefinedForMessage, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_TagNotDefinedForMessage(*args) try: self.this.append(this) except: self.this = this
| 473,793
|
def __init__(self, *args): this = apply(_quickfix.new_NoTagValue, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_NoTagValue(*args) try: self.this.append(this) except: self.this = this
| 473,794
|
def __init__(self, *args): this = apply(_quickfix.new_IncorrectTagValue, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_IncorrectTagValue(*args) try: self.this.append(this) except: self.this = this
| 473,795
|
def __init__(self, *args): this = apply(_quickfix.new_IncorrectDataFormat, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_IncorrectDataFormat(*args) try: self.this.append(this) except: self.this = this
| 473,796
|
def __init__(self, *args): this = apply(_quickfix.new_IncorrectMessageStructure, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_IncorrectMessageStructure(*args) try: self.this.append(this) except: self.this = this
| 473,797
|
def __init__(self, *args): this = apply(_quickfix.new_DuplicateFieldNumber, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_DuplicateFieldNumber(*args) try: self.this.append(this) except: self.this = this
| 473,798
|
def __init__(self, *args): this = apply(_quickfix.new_InvalidMessageType, args) try: self.this.append(this) except: self.this = this
|
def __init__(self, *args): this = _quickfix.new_InvalidMessageType(*args) try: self.this.append(this) except: self.this = this
| 473,799
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.