コード例 #1
0
def main():
    db_setup.global_init()

    print(Fore.BLUE, "Hotel service", Fore.RESET)
    commands()

    apartments = Apartment_service()
    guests = Guest_service()
    reservations = Reservation_service()

    while True:
        action = get_action()
        with switch(action) as s:
            s.case('l', apartments.apartments_list)
            s.case('a', apartments.add_apartment)
            s.case('s', apartments.search_apartment)
            s.case('v', guests.guest_list)
            s.case('g', guests.add_guest)
            s.case('b', reservations.reservation_list)
            s.case('m', reservations.add_reservation)
            s.case('?', commands)
            s.case('e', exit)
            s.default(lambda: print("Sorry, this is unknown command"))
コード例 #2
0
ファイル: client.py プロジェクト: yura7k/python_course
def main():
    db_setup.global_init()
    print(Fore.BLUE, "Hotel service", Fore.RESET)

    commands()

    apartments = Apartment_service()
    guests = Guest_service()
    bookings = Booking_service()

    while True:
        action = get_action()
        with switch(action) as s:
            s.case('l', apartments.apartments_list)
            s.case('a', apartments.apartments_add)
            s.case('s', apartments.search_apartment)
            s.case('v', guests.guest_list)
            s.case('g', guests.guest_add)
            s.case('b', bookings.booking_list)
            s.case('sg', bookings.booking_seach_by_name)
            s.case('m', bookings.booking_add)
            s.case('?', commands)
            s.case('e', exit)
            s.default(lambda: print("Sory? this is not comand"))
コード例 #3
0
def main_three(reportType, out_file):
    import services.mongo_setup as mongo_setup
    import services.data_service as data_service
    mongo_setup.global_init()
    sample_tweet = data_service.find_tweet_by_mood(report=reportType).all()
    rep_list = list()
    print('Start appending')
    for e in sample_tweet:
        text = e.text
        report = e.report
        id = e.tweetID
        if text.find("@nadidoesart") >= 1:
            print('SKIP')
            continue
        d = pd.DataFrame.from_dict({
            'id': id,
            'text': text,
            'report': report
        },
                                   orient='index').T
        rep_list.append(d)
    print('Done appending')
    data = pd.concat(rep_list)
    data.to_csv(out_file)
コード例 #4
0
        """  Stream in tweets and add them to the database 

        """
        rep = status._json
        (id,cont,fin_senti)= self.tweet_process(rep) #this does the sentiment analysis j
        data_service.create_finding(id,cont,fin_senti) #this adds to the datbase 
        return (True,)
    def on_error(self,status): 
        return status
    def tweet_process(self,tweet): 
        """  takes a tweet runs it through a simple sentiment analyzer. returns the id and content in a dataframe 
        """
        id = str(tweet['id'])
        try: 
            content = tweet['extended_tweet']['full_text']
        except KeyError: 
            content = tweet['text']
        output =sentiments[self.classy(content)]
        return (id,content,output) 
def main():
    #initialize using twitter api. these are my enviroment keys 
    auth = tweepy.OAuthHandler(os.environ['API_KEY'], os.environ['API_SECRET_KEY'])
    auth.set_access_token(os.environ['T_ACCESS'], os.environ['T_SECRET'])
    api = tweepy.API(auth)
    classi = text2pred()
    myListen = MyStreamListener(classy=classi) 
    myStream = tweepy.Stream(auth=api.auth,listener=myListen)
    myStream.filter(track=['breast cancer', 'breast lump','breast pain']) #term we'll be tracking. Using debate  currently for the sake of simplicity 
if __name__=="__main__":
    mongo_setup.global_init()
    main()
コード例 #5
0
    @Slot()
    def ShowUsers(self):
        print("Show users")
        self.closeMainWindow()
        guests_window = GuestsWindow(self.mdi)
        guests_window.destroyed.connect(self.ShowMainWindow)

    @Slot()
    def ShowHelp(self):
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Information)
        msg.setText("This is help")
        msg.exec_()
        print("Help")

    def closeMainWindow(self):
        if self.main_window:
            self.main_window.close()
            self.main_window = None


db_setup.global_init()

app = QApplication(sys.argv)
mdi = MDIWindow()

mdi.setMaximumSize(800, 600)
mdi.setMinimumSize(800, 600)

mdi.show()
app.exec_()
    print('\n\n\t\t REQUEST RECEIVED IN MAIN LOOP \n')

    # Check the Request method
    if request.method == "POST":
        print("_____ Request method is post ______")

    elif request.method == "GET":
        print("_____ REQUEST method is GET _____")

    else:
        print("_____ METHOD of Request is Something Else _____")

    if request.is_json:

        print("//////// ---- HURRAH the requested data -IS- Json ---- \\\\\\\\")

    else:
        print(" ///// ---- The Request Type is NOT  JSON ---- \\\\\\")






# Run the stuff
if __name__ == '__main__':
    # Setup Mongo db
    mongodb_setup.global_init()

    app.run(debug=True, host='0.0.0.0', port=502)