def join_connection(): req_data = request.get_json() conn_id = req_data['_id'] fileName = req_data['fileName'] userId = req_data['userId'] p = Prediction() # fo = open(app.config['UPLOAD_FOLDER'] + "/" + "ad.enc",'rb').read() # # Decrypts the data, requires a user-input password # CSVplaintext = decrypt('USERPASSWORD', fo).decode('utf8') # #create a temp csv-like file to pass to pandas.read_csv() # DATA=StringIO(CSVplaintext) # # Makes a panda dataframe with the data # df = pd.read_excel(DATA) # print df.head() value = int(p.run(app.config['UPLOAD_FOLDER'] + "/Data/" + fileName)) #conn_id = '5bf8ab7c101c372f28c65c2b' users = mongo.db.users connections = mongo.db.connections parser = connections.find({'_id': ObjectId(conn_id)}) for doc in parser: connDoc = doc currCount = connDoc['currRemainingCount'] if currCount > 0: playerNum = connDoc['userCount'] - (currCount - 1) print os.system('pwd') command = 'python ./../viff-1.0/apps/sum.py --no-ssl player-' + str( playerNum) + '.ini ' + str(value) print command print connections.update({'_id': ObjectId(conn_id)}, {'$inc': { 'currRemainingCount': -1 }}) #os.system(command) proc = Popen(command, shell=True, stdin=None, stdout=None, stderr=None, close_fds=True) print "Status = " + str(proc) status = 0 if status == 0: #print output value *= 100 users.insert({ 'userId': str(userId), 'yourVal': value, 'AvgValue': 0 }) retVal = {} retVal['sum'] = 'Will be updated soon!' return jsonify(retVal), 200 else: 'Joining Failed', 404 else: return 'Connection Full', 404
class MainWindow( QMainWindow ): """Class implementing GUI""" def __init__( self ): """Constructor.""" super( QMainWindow, self ).__init__( ) self.setGeometry(10, 50, 300, 150) self.setWindowTitle("Informative or NonInformative Tweets") self.filename = "" self.prediction = Prediction( "../models/text.h5", "../models/old_image/damage.h5" ) self.widget = QWidget ( ) self.widget.setObjectName("widget") self.widget.setStyleSheet("QWidget#widget{border-image:url('../images/background.jpg');}\n") self.layout = QGridLayout( self.widget ) self.image_label = QLabel( ) self.result_label = QLabel( ) self.image_label .setScaledContents( True ) self.result_label.setScaledContents( True ) self.browse = QPushButton( "Browse" ) self.text_field = QLineEdit ( ) self.submit = QPushButton( "Submit" ) self.layout.addWidget( self.image_label ) self.layout.addWidget( self.browse ) self.layout.addWidget( self.text_field ) self.layout.addWidget( self.submit ) self.layout.addWidget( self.result_label ) self.browse.clicked.connect( self.pick_file ) self.submit.clicked.connect( self.predict ) self.setCentralWidget( self.widget ) def pick_file( self ): """For selecting a file.""" self.filename = QFileDialog.getOpenFileName( )[ 0 ] if self.filename != "": pixmap = QPixmap ( self.filename ) self.image_label.setPixmap( pixmap ) def predict( self ): if self.filename != "": image = cv2.imread( self.filename ) text = self.text_field.text( ) im_class, txt_class = self.prediction.run( image, text ) if im_class == 0 and txt_class == 0: self.result_label.setText( "<font color='red'>Informative</font>" ) else: self.result_label.setText( "<font color='green'>Non-Informative</font>" )