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 upload(name): """ This page allows a user to upload a text or image file. """ error = valid_user(name) if error is None: if request.method == 'POST': file = request.files['file'] if file and valid_file(file.filename): # Sanitize the filename, save the file to the uploads # folder, and add the file and owner info to the file database. filename = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) file_instance = Upload(name, filename) flash('File was uploaded successfully.') return redirect(url_for('files', name=name)) else: flash("Invalid filename or file type.") return render_template('upload.html') # If an error occurs, display the error and # redirect to the appropriate page. display(error) if 'logged_in' in session: return redirect(url_for('upload', name=session['logged_in'])) else: return redirect(url_for('login'))
def __upload_avatar(self): """ Upload the avatar """ self.image = request.files['file'] if not self.message is None: return False if len(self.image.filename) > 3: up = Upload(self.user['username'], self.image) # ~ if not up.allowed_file(): self.message = g.users_msg('error_upload_1') # ~ elif not up.check_aspect_ratio(1): self.message = g.users_msg('error_upload_2') # ~ else: up.avatar_upload() self.list_images = up.names_list return True return False
def __init__(self, file, session, ydm, config=Config()): self.session = session self.config = config.config self.ydm = ydm self.callback = "jQuery32103773561319591048_1534950307354" upload = Upload(file, self.session, self.callback) self.info = upload.main() self.submit = self.submit()
def addNewTasks(self): if self.lock.acquire(True): try: if self.running: #logging.debug("task complete! time for next task!") if isinstance(self.currentTask, Upload): #logging.debug('we completed a download') # after downloading - we check for uploads # but first we relax for 5 seconds # it's important to relax - to give swfit a few # seconds to catch up if not self.currentTask.hadWorkToDo: # if you didn't have any work to do - take a break! if not self._starting: self.taskList.put(Sleep(self.updateInterval)) else: #logging.info('there was work to do - no resting!') pass download = Download(self.objectStore, self.outputQueue) self.taskList.put(download) self._starting = False elif isinstance(self.currentTask, Download): #logging.debug('we completed a upload') if not self.currentTask.hadWorkToDo: # if you didn't have any work to do - take a break! if not self._starting: self.taskList.put(Sleep(self.updateInterval)) else: #logging.info('there was work to do - no resting!') pass upload = Upload(self.objectStore, self.outputQueue) self.taskList.put(upload) self._starting = False elif isinstance(self.currentTask, Authenticate): if self.currentTask.isAuthenticated: #upload = Upload(self.objectStore, # self.outputQueue) #self.taskList.put(upload) download = Download(self.objectStore, self.outputQueue) self.taskList.put(download) else: sleep = Sleep(self.currentTask.retryWait) #logging.info('failed to auth' # ' - sleeping for %r' # % self.currentTask.retryWait) self.taskList.put(sleep) self.taskList.put(self.currentTask) elif isinstance(self.currentTask, Sleep): pass elif isinstance(self.currentTask, update.Update): if self.currentTask.hadWorkToDo: self.scheduleRestart() else: logging.warn('unhandeled task completion!') finally: self.lock.release()
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...')
async def upload(): print("Proceso upload inicializado") with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind(("127.0.0.1", 8000)) s.listen(0) while True: conn, addr = s.accept() client = Upload(conn, addr, torrent) client.start()
def main(): """Method to launch the app.""" content = DataMgt() if not content.is_database_empty(): # check content of table Product api = Api() api.load_data() # if yes, launch api request liste = Parser(api.api_result) # parse api result liste.clean() # clean api result data = Upload(liste.products_list) data.load_category() # upload table categories content data.load_products() # upload table products content session = App() session.start() # launch the client app
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 __init__(self): super(mywindow, self).__init__() self.setupUi(self) self.setWindowTitle("七牛上传辅助工具V1.0") self.putFileBtn.clicked.connect(self.submit) # 上传按钮 self.putUnityBtn.clicked.connect(self.submitUnity) # Unity热更新上传按钮 self.openFileBtn.clicked.connect(self.showFileSelector) # self.bucketSpinner.addItem("kingmahjong-test") # self.bucketSpinner.addItem("kingmahjong") for item in self.buckets: self.bucketSpinner.addItem(item["bucket"]) self.originPathEdit.setPlaceholderText('如C://aaa/abc/或C://aaa/abc.jpg') self.destPathEdit.setPlaceholderText( '如res/image/或res/image/abc.jpg(选填)') self.destPathEdit.textChanged.connect(self.resetUrl) self.originPathEdit.textChanged.connect(self.resetUrl) self.fileSignal.connect(self.printMsg) self.progressSignal.connect(self.updateProgress) self.upload = Upload()
def main(argv): try: # See Python3 getopt class for details on the short option configuration string format # https://docs.python.org/3/library/getopt.html short_options_config = _OPTION_HELP[1:] + _OPTION_INPUTFILE[1:] + ':' + _OPTION_OUTPUTFILE[1:] + ':' + _OPTION_DO_NOT_UPLOAD[1:] opts, args = getopt.getopt(argv, short_options_config) inventory_report_filename = '' inventory_report_html_filename = _DEFAULT_HTML_FILENAME upload_flag = True for opt, arg in opts: if opt == _OPTION_HELP: print_usage() sys.exit() elif opt == _OPTION_INPUTFILE: inventory_report_filename = validate_filename(arg) elif opt == _OPTION_OUTPUTFILE: inventory_report_html_filename = validate_filename(arg) elif opt == _OPTION_DO_NOT_UPLOAD: upload_flag = False json_inventory = read_csv_report(inventory_report_filename) write_json_inventory('inventory.json', json_inventory) write_html_inventory(inventory_report_html_filename, json_inventory) if upload_flag: upload = Upload(server='normsbeerandwine.com', username='******') upload.use_tls = False upload.filename = inventory_report_html_filename.name upload.password = '******' upload.connect() upload.upload_file() upload.disconnect() except Exception as e: print(e) print('') print_usage() sys.exit(2)
def main(): imgStoreQueue = Queue.Queue() smsQueue = Queue.Queue() logging.info ('Initializing Camera Module...') myCam = Camera('Camera', imgStoreQueue, smsQueue) myCam.setSaveLocation('/home/pi') logging.info ('Initializing Upload Module...') myUpload = Upload('Upload', imgStoreQueue, smsQueue) logging.info ('Initializing SMS Module...') logging.info ('App started. Press \'exit\' to quit program.') myCam.start() myUpload.start() try: while True: strInput = raw_input() if strInput == 'exit': if myCam.isAlive(): myCam.join() if myUpload.isAlive(): myUpload.join() break except KeyboardInterrupt as e: logging.info("Stopping...") if myCam.isAlive(): myCam.join() if myUpload.isAlive(): myUpload.join()
import sys from upload import Upload argvs = sys.argv test = Upload() print(test.upload(str(argvs[1])))
log.info('selected catalog folder: %s' % catalog_folder) if config['actions']['transform']: try: transform = Transform(config, catalog_folder) transform.transform_data() except Exception as e: log.error(e) exit(1) else: log.info('data transformed succesfully') if config['actions']['upload']: if config['debug_mode']: # Data with errors is logged and skipped in debug mode. # Do not allow potentialy broken data to be uploaded to Molgenis. log.warn('upload is not allowed in debug mode') else: try: upload = Upload(config) upload.delete_molgenis_entities() upload.zip_transformed_data() upload.upload_transformed_data_zip() upload.set_entities_permissions() upload.set_entity_indexing_depth('lifelines_subsection_variable') except Exception as e: log.error(e) exit(1) log.info('execution time: %s' % (timedelta(seconds=time.time() - startTime)))
print("prediction value: ") print(prediction_value) print("target value: ") print(y_value_raw[example]) # generate greyscale image data from prediction data prediction_imgdata = prediction * 255 prediction_imgdata = prediction_imgdata.astype(np.uint8) # generate greyscale image of target data target_imgdata = y_policy_raw[example] # merge image data in color channels merged_imgdata = np.stack([input_imgdata, prediction_imgdata, target_imgdata], axis=2) #create image img = Image.fromarray(merged_imgdata, 'RGB') img = img.resize(size=(img.size[0] * 10, img.size[1] * 10)) imgpath = logdest + "/" + os.path.basename(target_model).replace( '.h5', '') + "." + str(iteration) + ".png" img.save(imgpath) # upload results if upload: uploader = Upload() uploader.upload(modelPath, logpath, imgpath)
from entry import login import json def start(): print("Please Enter Your Name") name = input("> ") print("Welcome, {}".format(name)) key = "" if name.lower() == "toby": path = input("Enter full key path: ") key = login(name.lower(), path) else: key = login(name) return key if __name__ == "__main__": key = start() a = Upload(key) path = input("Enter file path> ") b,c= a.upload(path) print(b) print() print(c)
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...')
def run(self): time.sleep(1) locks.acquire() Upload(self.RedisServer, self.Num, self.ElasticServer) locks.release()
from hbo import HBO from netflix import Netflix from upload import Upload import datetime as dt print('hbo urls request started at: ', dt.datetime.now()) hbo = HBO() hbo.make_url_list() print('hbo url list produced at: ', dt.datetime.now()) # hbo.get_url_list() # hbo.read_urls_from_json() hbo.get_data() print('hbo data ready at: ', dt.datetime.now()) upload = Upload() upload.upload_file('hbo') print('netflix urls request started at: ', dt.datetime.now()) netflix = Netflix() netflix.make_urls() print('netflix url list produced at: ', dt.datetime.now()) # netflix.read_urls_from_json() netflix.get_data() print('netflix data ready at: ', dt.datetime.now()) upload.upload_file('netflix')
class Root(object): stream = Stream() video = Video() _cp_config = { 'tools.sessions.on': True, 'tools.auth.on': True, 'tools.sessions.locking': 'explicit', #this and the acquire_lock and the release_lock statements in the login and logout functions are necessary so that multiple ajax requests can be processed in parallel in a single session 'response.stream': True } upload = Upload() @cherrypy.expose def index(self): secrets_file = open("/home/ec2-user/secrets.txt") passwords = secrets_file.read().rstrip('\n') db_password = passwords.split('\n')[0] dbname = "estrewn" conn = MySQLdb.connect( host= 'estrewn-production-instance-1.cphov5mfizlt.us-west-2.rds.amazonaws.com', user='******', passwd=db_password, port=3306) curs = conn.cursor() curs.execute("use " + str(dbname) + ";") curs.execute("select unique_id from videos order by upload_time desc;") videos = curs.fetchall() for video in videos: assert (len(video) == 1) curs.execute( "update videos set last_accessed_time = now(6) where unique_id=" + str(video[0]) + ";") conn.commit() curs.execute("select IS_FREE_LOCK(\"" + str(video[0]) + "\")") isfreelock = bool(curs.fetchall()[0][0]) doesfileexist = os.path.isfile('/home/ec2-user/videos/' + str(video[0]) + '.mp4') while not (isfreelock and doesfileexist): time.sleep(1) curs.execute("select IS_FREE_LOCK(\"" + str(video[0]) + "\")") isfreelock = bool(curs.fetchall()[0][0]) doesfileexist = os.path.isfile('/home/ec2-user/videos/' + str(video[0]) + '.mp4') if (isfreelock and doesfileexist): break elif not doesfileexist and isfreelock: curs.execute("select GET_LOCK(\"" + str(video[0]) + "\",10)") got_lock = bool(curs.fetchall()[0][0]) if got_lock: curs.execute( "select video from videos where unique_id=" + str(video[0]) + ";") open('/home/ec2-user/videos/' + str(video[0]) + '.mp4', 'w').write(curs.fetchall()[0][0]) curs.execute("select RELEASE_LOCK(\"" + str(video[0]) + "\")") break conn.close() video_html_string = "" for video in videos: assert (len(video) == 1) video_html_string += "<center><video width=\"640\" height=\"480\" controls> <source src=\"/stream/?video_id=" + str( video[0]) + "\" type=\"video/mp4\"></video></center>" is_mobile = False if "User-Agent" in cherrypy.request.headers and is_mobile_user_agent( cherrypy.request.headers['User-Agent']): is_mobile = True if is_mobile: html_string = """ <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> Estrewn </title> <style> nav a, button { min-width: 48px; min-height: 48px; } html, body { height: 100%; width: 100%; margin-top:0; margin-left:0; margin-right:0; } a#menu svg { width: 40px; fill: #000; } main { width: 100%; height: 100%; } nav { width: 250px; height: 100%; position: fixed; transform: translate(-250px, 0); transition: transform 0.3s ease; } nav.open { transform: translate(0, 0); } .header { float : right } .content { padding-left:1em; padding-right:1em; } .divider { width:100%; height:1px; background-color:#dae1e9; } </style> </head> <body> <nav id="drawer" style="background-color:LightGrey"> <center><h2 style="margin-top:0">Estrewn</h2></center> <ul style="list-style:none;font-size:20px;padding-left:40px;"> <li style="padding-bottom:20px"><a href="/">Home</a></li> <li style="padding-bottom:20px"><a href="/upload/">Upload</a></li> </ul> </nav> <main> <div style = "width:100%;top:0;left:0;"> <a id="menu"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <path d="M2 6h20v3H2zm0 5h20v3H2zm0 5h20v3H2z" /> </svg> </a> <div class = "header"> <h1 style="margin-top:0;margin-bottom:0">Estrewn</h1> </div> </div> <center><h1> Estrewn </h1></center> <center><h3>A pile of digital content</h3></center> """ + video_html_string + """ <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.0.js"></script> <script type="text/javascript"> var menu = document.querySelector('#menu'); var main = document.querySelector('main'); var drawer = document.querySelector('#drawer'); menu.addEventListener('click', function(e) { drawer.classList.toggle('open'); e.stopPropagation(); }); main.addEventListener('click', function() { drawer.classList.remove('open'); }); main.addEventListener('touchstart', function() { drawer.classList.remove('open'); }); </script> <br> <div class="divider"></div> <br> <center>This website is experimental at this point. You should expect bugs, unexpected downtime, etc. Please contact [email protected] for comments, feature requests, etc.</center> <br><br> </body> </html> """ else: html_string = """ <html> <head> <title> Estrewn </title> <style> .divider { width:100%; height:0.1em; background-color:#dae1e9; } .nonheader { width:960px; margin: 80px auto 0px auto; } h1 { margin-top: 0.0em; margin-bottom: 0.0em; } h3 { margin-top: 0.0em; } .header1 {width:380px; float:left;} .nav { float: right; padding: 20px 0px 0px 0px; text-align: right; } header {background-color: White} header { position:fixed; top:0px; left:0px; width:100%; height:60px; z-index:50; } .page{ width:960px; margin:0px auto 0px auto; } </style> </head> <body> <header> <div class = "page"> <div class = "header1"> <h1>Estrewn</h1> <h3>A pile of digital content</h3> </div> <div class="nav"> <a href="/">Home</a> / <a href="/upload/">Upload</a> </div> </div> </header> <div class="nonheader"> <div class="divider"></div>\n <center><h1> Estrewn </h1></center> <center><h3>A pile of digital content</h3></center> """ + video_html_string + """ </div> <br> <div class="divider"></div> <br> <center>This website is experimental at this point. You should expect bugs, unexpected downtime, etc. Please contact [email protected] for comments, feature requests, etc.</center> <br><br> </body> </html> """ return html_string
def test_upload(): """upload""" upload = Upload() assert isinstance(upload.dataset, dict)
#!/user/bin/python3 # -*- coding:utf-8 -*- ''' test ''' __author__ = 'Hijac Wu' from upload import Upload x = Upload() x.setBucketName("kingmahjong-test") originPath = './sync/bbb.png' destPath = 'my-python-logo1.png' x.putFile(originPath, destPath)
def click_continue(self): self.selenium.find_element(*self._continue_locator).click() from upload import Upload return Upload(self.base_url, self.selenium)