def handleClaim(packtpub, args, config, dir_path): if args.dev: log_json(packtpub.info) log_success('[+] book successfully claimed') upload = None upload_info = None if not args.claimOnly: types = parse_types(args) packtpub.download_ebooks(types, dir_path) if args.extras: packtpub.download_extras(dir_path) if args.archive: raise NotImplementedError('not implemented yet!') if args.upload is not None: upload = Upload(config, args.upload) upload.run(packtpub.info['paths']) if upload is not None and upload is not SERVICE_DRIVE: log_warn('[-] skip store info: missing upload info') elif args.store is not None: Database(config, args.store, packtpub.info, upload.info).store() if args.notify: if upload is not None: upload_info = upload.info Notify(config, packtpub.info, upload_info, args.notify).run()
def main(): parser = argparse.ArgumentParser( description='Download FREE eBook every day from www.packtpub.com', formatter_class=argparse.ArgumentDefaultsHelpFormatter, version='1.3.0') parser.add_argument('-c', '--config', required=True, help='configuration file') parser.add_argument('-d', '--dev', action='store_true', help='only for development') parser.add_argument('-e', '--extras', action='store_true', help='download source code (if exists) and book cover') parser.add_argument('-u', '--upload', choices=[SERVICE_DRIVE, SERVICE_DROPBOX], help='upload to cloud') parser.add_argument('-a', '--archive', action='store_true', help='compress all file') parser.add_argument('-n', '--notify', action='store_true', help='notify via email') parser.add_argument('-s', '--store', choices=[DB_FIREBASE], help='store info') group = parser.add_mutually_exclusive_group() group.add_argument('-t', '--type', choices=['pdf', 'epub', 'mobi'], default='pdf', help='specify eBook type') group.add_argument('--all', dest='types', action='store_const', const=['pdf', 'epub', 'mobi'], help='all eBook types') args = parser.parse_args() try: #ip_address() config = config_file(args.config) types = parse_types(args) packpub = Packpub(config, args.dev) packpub.run() log_json(packpub.info) packpub.download_ebooks(types) if args.extras: packpub.download_extras() if args.archive: raise NotImplementedError('not implemented yet!') upload = None if args.upload is not None: upload = Upload(config, args.upload) upload.run(packpub.info['paths']) if upload is None: log_warn('[-] skip store info: missing upload info') log_warn('[-] skip notification: missing upload info') else: if args.store is not None: Database(config, args.store, packpub.info, upload.info).store() if args.notify: Notify(config, packpub.info, upload.info).send_email() except KeyboardInterrupt: log_error('[-] interrupted manually') except Exception as e: log_debug(e) log_error('[-] something weird occurred, exiting...')
def main(): parser = argparse.ArgumentParser( description='Download FREE eBook every day from www.packtpub.com', formatter_class=argparse.ArgumentDefaultsHelpFormatter, version='1.0') parser.add_argument('-c', '--config', required=True, help='configuration file') parser.add_argument('-d', '--dev', action='store_true', help='only for development') parser.add_argument('-e', '--extras', action='store_true', help='download source code (if exists) and book cover') parser.add_argument('-u', '--upload', choices=[SERVICE_DRIVE, SERVICE_DROPBOX], help='upload to cloud') parser.add_argument('-a', '--archive', action='store_true', help='compress all file') parser.add_argument('-n', '--notify', action='store_true', help='notify via email') parser.add_argument('-D', '--debug', action='store_true', help='only for debugging') group = parser.add_mutually_exclusive_group() group.add_argument('-t', '--type', choices=['pdf', 'epub', 'mobi'], default='pdf', help='specify eBook type') group.add_argument('--all', dest='types', action='store_const', const=['pdf', 'epub', 'mobi'], help='all eBook types') args = parser.parse_args() try: #ip_address() config = config_file(args.config) types = parse_types(args) packpub = Packpub(config, args.dev) if args.debug: #Dumping responses into files packpub.set_debug() packpub.run() log_json(packpub.info) packpub.download_ebooks(types) if args.extras: packpub.download_extras() if args.archive: raise NotImplementedError('not implemented yet!') upload = None if args.upload is not None: upload = Upload(config, args.upload) upload.run(packpub.info['paths']) if args.notify: if upload is not None: Notify(config, packpub.info, upload.info).send_email() else: log_warn('[-] skip notification: missing upload info') except KeyboardInterrupt: log_error('[-] interrupted manually') except Exception as e: log_debug(e) log_error('[-] something weird occurred, exiting...')
def main(): parser = argparse.ArgumentParser( description="Download FREE eBook every day from www.packtpub.com", formatter_class=argparse.ArgumentDefaultsHelpFormatter, version="1.0", ) parser.add_argument("-c", "--config", required=True, help="configuration file") parser.add_argument("-d", "--dev", action="store_true", help="only for development") parser.add_argument("-e", "--extras", action="store_true", help="download source code (if exists) and book cover") parser.add_argument("-u", "--upload", choices=[SERVICE_DRIVE, SERVICE_DROPBOX], help="upload to cloud") parser.add_argument("-a", "--archive", action="store_true", help="compress all file") parser.add_argument("-n", "--notify", action="store_true", help="notify via email") group = parser.add_mutually_exclusive_group() group.add_argument("-t", "--type", choices=["pdf", "epub", "mobi"], default="pdf", help="specify eBook type") group.add_argument( "--all", dest="types", action="store_const", const=["pdf", "epub", "mobi"], help="all eBook types" ) args = parser.parse_args() try: # ip_address() config = config_file(args.config) types = parse_types(args) packpub = Packpub(config, args.dev) packpub.run() log_json(packpub.info) packpub.download_ebooks(types) if args.extras: packpub.download_extras() if args.archive: raise NotImplementedError("not implemented yet!") upload = None if args.upload is not None: upload = Upload(config, args.upload) upload.run(packpub.info["paths"]) if args.notify: if upload is not None: Notify(config, packpub.info, upload.info).send_email() else: log_warn("[-] skip notification: missing upload info") except KeyboardInterrupt: log_error("[-] interrupted manually") except Exception as e: log_debug(e) log_error("[-] something weird occurred, exiting...")
def exec_upload(self): if self._module is not None: try: u = getattr(self._module.plugin, 'Upload')(self._config) except AttributeError: u = Upload(self._config) else: u = Upload(self._config) u.run() print 'Successfully uploaded the project.'
def upload(): program = optparse.OptionParser(usage='qiniu_upload upload [OPTIONS]', add_help_option=False) program.add_option('--config', '-c', help='set config path') program.add_option('--source', '-s', help='set local file(directory) path') options, arguments = program.parse_args() if options.config and options.source: if not path.exists(options.config): program.error('config file `%s` not found' % options.config) if not path.exists(options.source): program.error('local file(directory) `%s` not found' % options.source) upload = Upload(options.source, options.config) upload.run() else: program.print_help()
def upload(): program = optparse.OptionParser( usage = 'qiniu_upload upload [OPTIONS]', add_help_option = False ) program.add_option('--config', '-c', help = 'set config path') program.add_option('--source', '-s', help = 'set local file(directory) path') options, arguments = program.parse_args() if options.config and options.source: if not path.exists(options.config): program.error('config file `%s` not found' % options.config) if not path.exists(options.source): program.error('local file(directory) `%s` not found' % options.source) upload = Upload(options.source, options.config) upload.run() else: program.print_help()
def handleClaim(packtpub, args, config, dir_path): if args.dev: log_json(packtpub.info) log_success('[+] book successfully claimed') upload = None upload_info = None if not args.claimOnly: types = parse_types(args) packtpub.download_ebooks(types, dir_path) if args.extras: packtpub.download_extras(dir_path) if args.archive: raise NotImplementedError('not implemented yet!') if args.upload is not None: upload = Upload(config, args.upload) upload.run(packtpub.info['paths']) if args.store is not None: if args.upload == SERVICE_GOOGLE_DRIVE or args.upload == SERVICE_ONEDRIVE: Database(config, args.store, packtpub.info, upload.info).store() else: log_warn('[-] skip store info: missing upload info') if args.notify: if upload is not None: upload_info = upload.info Notify(config, packtpub.info, upload_info, args.notify).run()
def main(): parser = argparse.ArgumentParser( description='Download FREE eBook every day from www.packtpub.com', formatter_class=argparse.ArgumentDefaultsHelpFormatter, version='2.1.0') parser.add_argument('-c', '--config', required=True, help='configuration file') parser.add_argument('-d', '--dev', action='store_true', help='only for development') parser.add_argument('-e', '--extras', action='store_true', help='download source code (if exists) and book cover') parser.add_argument('-u', '--upload', choices=[SERVICE_DRIVE, SERVICE_DROPBOX, SERVICE_SCP], help='upload to cloud') parser.add_argument('-a', '--archive', action='store_true', help='compress all file') parser.add_argument('-n', '--notify', choices=[SERVICE_GMAIL, SERVICE_IFTTT, SERVICE_JOIN], help='notify after claim/download') parser.add_argument('-s', '--store', choices=[DB_FIREBASE], help='store info') parser.add_argument('-o', '--claimOnly', action='store_true', help='only claim books (no downloads/uploads)') group = parser.add_mutually_exclusive_group() group.add_argument('-t', '--type', choices=['pdf', 'epub', 'mobi'], default='pdf', help='specify eBook type') group.add_argument('--all', dest='types', action='store_const', const=['pdf', 'epub', 'mobi'], help='all eBook types') args = parser.parse_args() now = datetime.datetime.now() log_info('[*] {date} - Fetching today\'s books'.format( date=now.strftime("%Y-%m-%d %H:%M"))) try: #ip_address() config = config_file(args.config) types = parse_types(args) packpub = Packpub(config, args.dev) packpub.run() if args.dev: log_json(packpub.info) log_success('[+] book successfully claimed') upload = None if not args.claimOnly: packpub.download_ebooks(types) if args.extras: packpub.download_extras() if args.archive: raise NotImplementedError('not implemented yet!') if args.upload is not None: upload = Upload(config, args.upload) upload.run(packpub.info['paths']) if upload is not None and upload is not SERVICE_DRIVE: log_warn('[-] skip store info: missing upload info') elif args.store is not None: Database(config, args.store, packpub.info, upload.info).store() if args.notify: upload_info = None if upload is not None: upload_info = upload.info Notify(config, packpub.info, upload_info, args.notify).run() except KeyboardInterrupt: log_error('[-] interrupted manually') except Exception as e: log_debug(e) log_error('[-] something weird occurred, exiting...')