示例#1
0
    def start(self):
        logger.info("Starting curses display loop")

        # Initial render.
        self.render()

        while self._running:
            # Time how long it takes to process input
            # and render the screen.
            with common.ContextDuration() as t:
                # Handle user input.
                self.process_input()

                # Do any calculations related to rendering.
                self.render_calcs()

                # Execute the periodic call backs.
                for periodic in self.periodics:
                    periodic.update(time.time())

            # Are we still running?
            self._running = self.state.is_running()

            # Sleep for an amount of time.
            sleep_time = self.PROGRAM_PERIOD - t.duration
            if sleep_time > 0:
                time.sleep(sleep_time)

        # Tear down the display.
        logger.debug("Tearing down curses display")
        uc.endwin()
        common.clear()
示例#2
0
def commenter():
    subreddit = reddit.subreddit('all')
    while True:
        for submission in subreddit.new(limit=2):
            if re.search("", submission.title, re.IGNORECASE):
                print(submission.title, "\n")
                chooser = input("Would you like to upvote this post?[y/n]")
                decider = rando.choice(numbers)
                if decider > 500 and chooser.lower() == "y":
                    submission.upvote()
                    upvote = True
                elif chooser.lower() or decider < 500 == "n":
                    upvote = False
                print("Bot interacting with:", submission.title, "\n")
                print("Submission ID: ", submission.id, "\n")
                print("The author is:", submission.author, "\n")
                print("the post's score is:", submission.score, "\n")
                print("The decider is:", decider, "\n")
                if upvote == True:
                    print("I upvoted\n")
                elif upvote == False:
                    print("Didn't upvote\n")
                author = str(submission.author)
                if reddit.redditor(
                        author
                ).has_verified_email == True and decider > 500 and upvote == True:
                    if submission.id not in posts_replied_to:
                        reddit.redditor(author).message(
                            "Hey", "I hope you have a great day")
                        posts_replied_to.append(submission.id)
                        print("I PM'd", submission.author)
                print("\n")
                time.sleep(2)
                clear()
                readInbox()
示例#3
0
def transform(expr, fout, options):
    dot = yuml2dot(expr, options)

    if options.png or options.svg:
        import subprocess
        import StringIO

        svg = subprocess.Popen(['dot', '-Tsvg'], stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate(input=dot)[0]
        
        etree.register_namespace('', 'http://www.w3.org/2000/svg')
        root = etree.parse(StringIO.StringIO(svg)).getroot()
        
        common.clear(root)

        if options.scruffy:
            import scruffy

            scruffy.transform(root, options)

        svg = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n' + etree.tostring(root) + '\n'

        if options.png:
            png = subprocess.Popen(['convert', '-', '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate(input=svg)[0]
            fout.write(png)
        elif options.svg:
            fout.write(svg)
    else:
        fout.write(dot)
示例#4
0
def FILE_ml_pkl():
    test_dir = (
        Path(path_config.LOCAL_DIR)
        / testing_config.TESTDATA_FOLDER
        / testing_config.TESTDATA_VERSION
    )
    perm_pkl = test_dir / "perm/models/ml.pkl"
    temp_pkl = test_dir / "temp/models/ml.pkl"
    clear(temp_pkl)
    temp_pkl.parent.mkdir(parents=True, exist_ok=True)  # pylint: disable=no-member
    shutil.copy2(str(perm_pkl), str(temp_pkl))
    yield temp_pkl
    clear(temp_pkl)
示例#5
0
def readInbox():
    reddit = praw.Reddit('bot1')

    for x in range(1):
        for message in reddit.inbox.unread(limit=10):
            print(message.body, "\n")
            author = str(message.author)
            subject_of_msg = input(
                "What would you like the subject of the reply to be?\n")
            body_of_msg = input(
                "What would you like the body of the reply to be?\n")
            reddit.redditor(author).message(subject_of_msg, body_of_msg)
            print("Message Sent To:", author)
            message.mark_read()
            clear()
def FILE_grd_path():
    test_dir = (
        Path(path_config.LOCAL_DIR)
        / testing_config.TESTDATA_FOLDER
        / testing_config.TESTDATA_VERSION
    )
    perm_grd = (
        test_dir
        / "perm/S1A_IW_GRDH_1SDV_20200406T194140_20200406T194205_032011_03B2AB_C112/vv_grd.tiff"
    )
    temp_grd = (
        test_dir
        / "temp/S1A_IW_GRDH_1SDV_20200406T194140_20200406T194205_032011_03B2AB_C112/vv_grd.tiff"
    )
    clear(temp_grd)
    temp_grd.parent.mkdir(parents=True, exist_ok=True)  # pylint: disable=no-member
    shutil.copy2(str(perm_grd), str(temp_grd))
    yield temp_grd
    clear(temp_grd)
def FILE_ocn_path():
    test_dir = (
        Path(path_config.LOCAL_DIR)
        / testing_config.TESTDATA_FOLDER
        / testing_config.TESTDATA_VERSION
    )
    perm_ocn = (
        test_dir
        / "perm/S1A_IW_OCN__2SDV_20200406T194140_20200406T194205_032011_03B2AB_4913/ocn.zip"
    )
    temp_ocn = (
        test_dir
        / "temp/S1A_IW_OCN__2SDV_20200406T194140_20200406T194205_032011_03B2AB_4913/ocn.zip"
    )
    clear(temp_ocn)
    temp_ocn.parent.mkdir(parents=True, exist_ok=True)  # pylint: disable=no-member
    shutil.copy2(str(perm_ocn), str(temp_ocn))
    yield temp_ocn
    clear(temp_ocn)
示例#8
0
def new_vehicle_registration(conn):
    while True:
        common.clear()
        print_opts()

        line = sys.stdin.readline()
        if not line:
           return
        line = line.rstrip()
        if line == 'exit':
            return
        
        common.clear()

        try:
            r = None
            if line == '1':
                r = register_vehicle(conn)
            elif line == '2':
                r = register_person(conn)
            elif line == '3':
                r = add_owner(conn)
            elif line == '4':
                r = view_vehicle_types(conn)
            else:
                print('Invalid option!')
            
            if r == None:
                print('Operation cancelled.')
            elif r == True:
                print('Operation succeeded.')
            elif r == False:
                print('Operation failed.')
            
        except cx_Oracle.DatabaseError as e:
            print('Untreated exception...')
            error, = e.args
            print("Oracle-Error-Code:", error.code)
            print("Oracle-Error-Offset:", error.offset)
            print("Oracle-Error-Message:", error.message)
        sys.stdin.readline()
示例#9
0
def readInbox():
    for x in range(1):
            for item in reddit.inbox.unread(limit=10):
                    if isinstance(item, Message):
                        print("This is a private message")
                        time.sleep(2)
                        clear()
                        print(item.body , "\n")
                        author = str(item.author)
                        body_of_msg = input("What would you like the body of the reply to be?\n")
                        item.reply(body_of_msg)
                        print("Message Sent To:",author)
                        item.mark_read()
                        clear()
                    else:
                        print("This is a submission reply\n")
                        print(item.body)
                        author = str(item.author)
                        replyOrNah = input("Would you like to reply to this?[y/n]")
                        if replyOrNah.lower() == "y":
                            clear()
                            user_comment_reply = input("What would you like to reply to this?")
                            item.reply(user_comment_reply)
                            print("Bot replied to", author)
                            item.mark_read()
                        elif replyOrNah.lower() == "n":
                            print("Ok. moving on...")
                            item.mark_read()
                        else:
                            item.mark_read()
示例#10
0
def violation_record(conn):

    while True:
        common.clear()
        print_opts()

        line = sys.stdin.readline()
        if not line:
            return
        line = line.rstrip()
        if line == 'exit':
            return
	
        common.clear()
        
        try:
            r = None
            if line == '1':
                r = add_ticket(conn)
            
            if line == '2':
                r = primary_owner_ticket(conn)
                
            else:
                print('Invalid option!')
            
            if r == None:
                print('Operation cancelled.')
            elif r == True:
                print('Operation succeeded.')
            elif r == False:
                print('Operation failed.')
            
        except cx_Oracle.DatabaseError as e:
            print('Untreated exception...')
            error, = e.args
            print("Oracle-Error-Code:", error.code)
            print("Oracle-Error-Offset:", error.offset)
            print("Oracle-Error-Message:", error.message)
            sys.stdin.readline()
import time
import os
import re
from common import clear
from readinbox import readInbox

reddit = praw.Reddit('bot1')

subreddit = reddit.subreddit('all')
posts_already_seen = []
while True:
    for submission in subreddit.new(limit=10):
        if submission.subreddit == "catloversyay2019":  #this subreddit is just weird man. check it out for yourself if you don't believe me.
            print("nah lol this sub weird")
            time.sleep(2)
            clear()
        if submission.subreddit.over18 == True:  #Lol Not letting you see that stuff by default.
            print("This subreddit is NSFW")
            time.sleep(2)
            clear()
        elif re.search("", submission.title, re.IGNORECASE):
            if submission.is_self:
                if submission.id not in posts_already_seen:
                    print("This was posted in", submission.subreddit, '\n')
                    print(submission.title, '\n')
                    print(submission.selftext, '\n')
                    posts_already_seen.append(submission.id)
                    commentAsk = input(
                        "Would you like to comment on this?[y/n]")
                    if commentAsk.lower() == "y":
                        clear()
示例#12
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions = [
        "Show table", "Add elements", "Remove element by it's ID",
        "Update an element", "Get counts by manufacturer",
        "Get averege products"
    ]

    table = data_manager.get_table_from_file("store/games_test.csv")
    ui.print_menu("Store Manager MENU", special_functions,
                  "go back to Main Menu.")
    choice = ui.get_inputs(" ", "What's your choice?")
    choice = common.check_one_input_for_number(choice, " ",
                                               "What's your choice?")

    while choice != 0:
        if choice == 1:  #show, choice[0] because from the user inputs we get lists
            show_table(table)

        elif choice == 2:  #add
            add(table)
            data_manager.write_table_to_file("store/games_test.csv", table)

        elif choice == 3:  #remove
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            remove(table, id)
            data_manager.write_table_to_file("store/games_test.csv", table)

        elif choice == 4:  #update
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            update(table, id)
            data_manager.write_table_to_file("store/games_test.csv", table)

        elif choice == 5:  #counts
            ui.print_result(
                get_counts_by_manufacturers(table),
                "This many different kinds of games are available for each manufacturer:"
            )

        elif choice == 6:  #avg by manufac
            manufacturer = ui.get_inputs(" ", "Add the manufacturer")
            manufacturer = manufacturer[0]
            ui.print_result(
                get_average_by_manufacturer(table, manufacturer),
                "The average amount of games in stock of a given manufacturer is:"
            )

        else:
            ui.print_error_message("Wrong input!")

        ui.print_menu("Store Manager MENU", special_functions,
                      "go back to Main Menu.")
        choice = ui.get_inputs(" ", "What's your choice?")
        choice = common.check_one_input_for_number(choice, " ",
                                                   "What's your choice?")
        common.clear()

    common.clear()
示例#13
0
            while 0 >= count:
                print 'Enter rows count for "Ticket":',
                try:
                    count = int(input())
                except ValueError:
                    print 'Bad number'
                    continue
                if 0 >= count:
                    print 'Number of rows must be positive'
                    continue
            import ticket
            ticket.populate(db, count)
        else:
            import importlib
            t = importlib.import_module(args.table.lower())
            t.populate(db, args.number)
    else:
        import common
        if args.table == 'All':
            common.clear(db, 'Airport')
            common.clear(db, 'Plane')
            common.clear(db, 'Person')
            common.clear(db, 'Rating')
        else:
            common.clear(db, args.table)
else:
    print 'There is no such table: {}'.format(args.table)
    close_connection_and_exit(1)

close_connection_and_exit(0)
def main():
    print("Informer systems booting up... Stand by...")
    time.sleep(2)
    comments_already_seen = []
    subreddit = reddit.subreddit(
        'MK11PremiumStore')  #The subreddit that it searches for the comments
    runNow = False
    #init setup. lets the user know that the bot isn't ready until it loops back to newer comments
    for comment in subreddit.stream.comments():
        comment_as_str = str(comment.body)
        if runNow == False:
            clear()
            print("Initialization Complete.")
            time.sleep(3)
            clear()
            print("Searching komments on", subreddit)
            runNow = True
        #if comment.distinguished:
        if comment.distinguished and comment.created_utc > start_time:  #Looks for comments that are, mod distinguished and were created after the bot was started
            if comment.stickied:  #If comment is stickied, performs the bot's action

                if 'kitana' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(Kitana_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Kitana Kahn is available")
                        comment.reply(
                            "Calling kombatants\n\n" + str(Kitana2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for that blue female ninja is available"
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(Kitana3_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Kitana is available. Why she called Kitana when she uses fans??"
                        )
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif 'jade' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(Jade_subs[0:]) + "\n\n\n" +
                                      "New kontent for Jade is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif 'kabal' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(Kabal_subs[0:]) + "\n\n\n" +
                                      "New kontent for Kabal is available")
                        comment.reply(
                            "Calling kombatants\n\n" + str(Kabal2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Speedy Gonzalez is available")
                        comment.reply("Calling kombatants\n\n" +
                                      str(Kabal3_subs[0:]) + "\n\n\n" +
                                      "New kontent for Flash is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif 'kung lao' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(KL_subs[0:]) + "\n\n\n" +
                                      "New kontent for Kung Lao is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif 'sub zero' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(SZ_subs[0:]) + "\n\n\n" +
                                      "New kontent for Sub-Zero is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif 'sub-zero' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(SZ_subs[0:]) + "\n\n\n" +
                                      "New kontent for Sub-Zero is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif 'scorpion' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(Scorpion_subs[0:]) + "\n\n\n" +
                                      "New kontent for Scorpion is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif 'cetrion' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(Cetrion_subs[0:]) + "\n\n\n" +
                                      "New kontent for Cetrion is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif 'frost' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(Frost_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Frost is available. Tell her I love her."
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(Frost2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Frost is available. Isn't she beautiful?"
                        )
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif 'baraka' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(Baraka_subs[0:]) + "\n\n\n" +
                                      "New kontent for Baraka is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif 'raiden' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(Raiden_subs[0:]) + "\n\n\n" +
                                      "New kontent for Raiden is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif 'shao kahn' in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(SK_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Shao Kahn is available. Finally, a real man."
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(SK2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Shao Kahn is available. Stop - Hammer time."
                        )
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "dvorah" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(DVH_subs[0:]) + "\n\n\n" +
                                      "New kontent for D'vorah is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "jax" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(Jax_subs[0:]) + "\n\n\n" +
                                      "New kontent for Jax is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "geras" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(Geras_subs[0:]) + "\n\n\n" +
                                      "New kontent for Geras is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "kano" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(Kano_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Kano is available. Remember the Kanos cereal?"
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(Kano2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Kano is available. Does he use Stark Industries tech?"
                        )
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "nightwolf" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(Nightwolf_subs[0:]) + "\n\n\n" +
                                      "New kontent for Nightwolf is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "cassie cage" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(CC_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Cassie Cage is available")
                        comment.reply(
                            "Calling kombatants\n\n" + str(CC2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Calamity Cage is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "cassie" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(CC_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Cassie Cage is available")
                        comment.reply(
                            "Calling kombatants\n\n" + str(CC2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Calamity Cage is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "kotal kahn" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(KK_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Kotal Kahn is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "kotal" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(KK_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Kotal Kahn is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "skarlet" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(Skarlet_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Skarlet is available. Bloody hell..."
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(Skarlet2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Skarlet is available. Blood for the Blood God!"
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(Skarlet3_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for that female red ninja is available."
                        )
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "sonya blade" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(SB_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Sonya Blade is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "sonya" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(SB_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Sonya Blade is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "shang tsung" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(ST_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Shang Tsung is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "shang" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(ST_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Shang Tsung is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "johnny cage" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(JC_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Johnny Cage is available. This guy isn't serious, is he?"
                        )
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "johnny" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(JC_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Johnny Cage is available. This guy isn't serious, is he?"
                        )
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "noob saibot" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(NS_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Noob Saibot is available. I refuse to stop making fun of your edgy boi."
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(NS2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Boob Saibot is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "noob" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(NS_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Noob Saibot is available. I refuse to stop making fun of your edgy boi."
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(NS2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Boob Saibot is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "kollector" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply("Calling kombatants\n\n" +
                                      str(Kollector_subs[0:]) + "\n\n\n" +
                                      "New kontent for Kollector is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "jacqui briggs" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(JB_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Jacqui Briggs is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "jacqui" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(JB_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Jacqui Briggs is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "liu kang" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(LK_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for The Chosen One is available")
                        comment.reply(
                            "Calling kombatants\n\n" + str(LK2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for The Dragon is available")
                        comment.reply(
                            "Calling kombatants\n\n" + str(LK3_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for the man with the dragon tatoo is available"
                        )
                        comment.reply("Calling kombatants\n\n" +
                                      str(LK4_subs[0:]) + "\n\n\n" +
                                      "New kontent for Liu Kang is available")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "erron black" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(EB_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Erron Black is available. Yeehaw."
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(EB2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Broke-Black-Mountain is available."
                        )
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "erron" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(EB_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Erron Black is available. Yeehaw."
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(EB2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for Broke-Black-Mountain is available."
                        )
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()

                elif "terminator" in comment.body.lower():
                    if comment.id not in comments_already_seen:
                        comment.reply(
                            "Calling kombatants\n\n" + str(TRM_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for the Terminator is available. Your Krystals...give them to me...now!"
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(TRM2_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for the Terminator is available. UZI Nine Milimetah..."
                        )
                        comment.reply(
                            "Calling kombatants\n\n" + str(TRM3_subs[0:]) +
                            "\n\n\n" +
                            "New kontent for the Terminator is terminable.")
                        comments_already_seen.append(comment.id)
                        print("Replied to", comment.body)
                        time.sleep(3)
                        clear()
示例#15
0
def clear(db):
    common.clear(db, 'Ticket')
示例#16
0
def rm_remote_src(host, dir_name):
    cmd = "rm -rf %s" % dir_name
    print("Remove remote host %s source dir: %s" % (host, dir_name))
    rcmd(host, cmd)


def scp_src_dir(host, dir_name):
    cmd = "scp -r {1} {0}:{1}".format(host, dir_name)
    print("Scp %s to remote host %s" % (dir_name, host))
    os.system(cmd)


if __name__ == "__main__":
    if len(sys.argv) == 2:
        config_file = sys.argv[1]
    elif len(sys.argv) == 1:
        config_file = './config_huawei.json'
    else:
        print("Example: \n"
              "  python3 upload.py\n"
              "  python3 upload.py ./config_huawei.json")
        exit(1)

    Config.config_file = config_file
    source_dir = Config.get_sources_dir()
    clear(source_dir)
    for host in Config.get_hosts():
        if host != local_ip:
            rm_remote_src(host, source_dir)
            scp_src_dir(host, source_dir)
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions = [
        "Show table", "Add elements", "Remove element by it's ID",
        "Update an element by it's ID", "Get longest name ID",
        "Get subscribed e-mails"
    ]

    table = data_manager.get_table_from_file("crm/customers_test.csv")
    ui.print_menu("Customer Relationship Management MENU", special_functions,
                  "go back to Main Menu.")
    choice = ui.get_inputs(" ", "What's your choice?")
    choice = common.check_one_input_for_number(choice, " ",
                                               "What's your choice?")

    while choice != 0:
        if choice == 1:  #show, choice[0] because from the user inputs we get lists
            show_table(table)

        elif choice == 2:  #add
            add(table)
            data_manager.write_table_to_file("crm/customers_test.csv", table)

        elif choice == 3:  #remove
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            remove(table, id)
            data_manager.write_table_to_file("crm/customers_test.csv", table)

        elif choice == 4:  #update
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            update(table, id)
            data_manager.write_table_to_file("crm/customers_test.csv", table)

        elif choice == 5:  #ID cust
            ui.print_result(get_longest_name_id(table),
                            "The ID of the customer is:")

        elif choice == 6:  #subscribed
            result = get_subscribed_emails(table)
            ui.print_result(
                result, "These customers have subscribed to the news letter:")

        else:
            ui.print_error_message("Wrong input!")

        ui.print_menu("Customer Relationship Management MENU",
                      special_functions, "go back to Main Menu.")
        choice = ui.get_inputs(" ", "What's your choice?")
        choice = common.check_one_input_for_number(choice, " ",
                                                   "What's your choice?")
        common.clear()

    common.clear()
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions=["Show table",
    "Add elements",
    "Remove element by it's ID",
    "Update an element",
    "Get which year has the highest profit",
    "Get what is the average profit in a given year?"]

    table=data_manager.get_table_from_file("accounting/items_test.csv")
    ui.print_menu("Accounting Manager MENU",special_functions,"go back to Main Menu.")
    choice=ui.get_inputs(" ","What's your choice?")
    choice=common.check_one_input_for_number(choice," ","What's your choice?")
    
    while choice!=0:
        if choice==1: #show, choice[0] because from the user inputs we get lists 
            show_table(table)

        elif choice==2: #add
            add(table)
            data_manager.write_table_to_file("accounting/items_test.csv",table)

        elif choice==3: #remove
            id=ui.get_inputs(" ","Add the searched ID")
            id=id[0]
            remove(table,id)
            data_manager.write_table_to_file("accounting/items_test.csv",table)

        elif choice==4: #update
            id=ui.get_inputs(" ","Add the searched ID")
            id=id[0]
            update(table,id)
            data_manager.write_table_to_file("accounting/items_test.csv",table)

        elif choice==5: #max
            ui.print_result(which_year_max(table),"The max profit's year: ")

        elif choice==6: #avg
            year=ui.get_inputs(" ","Add the year")
            year=year[0]
            result=avg_amount(table,year)
            if result!=None:
                ui.print_result(result,"The average profit in {0} is: ".format(year))

        else:
            ui.print_error_message("Wrong input!")
        
        ui.print_menu("Accounting Manager MENU",special_functions,"go back to Main Menu.")
        choice=ui.get_inputs(" ","What's your choice?")
        choice=common.check_one_input_for_number(choice," ","What's your choice?")
        
        common.clear()
        
    common.clear()
示例#19
0
    if my_version and latest_version and (my_version < latest_version):
        print("Version {}.{}.{} is now available".format(*latest_version))
        print("Run with -c after upgrading to clear your cache!".format(
            *latest_version))
        time.sleep(3)
    else:
        logger.info("Current version: %s", my_version)
        logger.info("Latest version:  %s", latest_version)


if __name__ == '__main__':
    # Get command line arguments.
    args = get_args()

    # Clear the console then print the title screen.
    common.clear()
    print(common.TITLE)

    # Check the version we're running.
    check_version()

    # Clear your auth keys.
    if args.clear_auth:
        logger.debug("Clearing authorization tokens")
        common.clear_auth(args.username)

    # Reset the cache.
    if args.clear_cache:
        logger.debug("Clearing the cache")
        common.clear_cache(args.username)
示例#20
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions = [
        "Show table", "Add elements", "Remove element by it's ID",
        "Update an element", "Get oldest person",
        "Get person whose closest to averege"
    ]

    table = data_manager.get_table_from_file("hr/persons_test.csv")
    ui.print_menu("Human Resources Manager MENU", special_functions,
                  "go back to Main Menu.")
    choice = ui.get_inputs(" ", "What's your choice?")
    choice = common.check_one_input_for_number(choice, " ",
                                               "What's your choice?")

    while choice != 0:
        if choice == 1:  #show
            show_table(table)

        elif choice == 2:  #add
            add(table)
            data_manager.write_table_to_file("hr/persons_test.csv", table)

        elif choice == 3:  #remove
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            remove(table, id)
            data_manager.write_table_to_file("hr/persons_test.csv", table)

        elif choice == 4:  #update
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            update(table, id)
            data_manager.write_table_to_file("hr/persons_test.csv", table)

        elif choice == 5:  #oldest
            ui.print_result(get_oldest_person(table),
                            "The oldest persons are:")

        elif choice == 6:  #closest to avg
            result = avg_amount(table, year)
            ui.print_result(result, "The person closest to average is:")

        else:
            ui.print_error_message("Wrong input!")

        ui.print_menu("Human Resources Manager MENU", special_functions,
                      "go back to Main Menu.")
        choice = ui.get_inputs(" ", "What's your choice?")
        choice = common.check_one_input_for_number(choice, " ",
                                                   "What's your choice?")
        common.clear()

    common.clear()
示例#21
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    common.clear()
    special_functions = [
        "Latest buyer name", "Last buyer ID",
        "The buyer name spent most and the money spent",
        "Get the buyer ID spent most and the money spent",
        "Get the most frequent buyers names",
        "Get the most frequent buyers IDs", "Get customer without purchase"
    ]

    ui.print_menu("Data Analyser MENU", special_functions,
                  "go back to Main Menu.")
    choice = ui.get_inputs(" ", "What's your choice?")
    choice = common.check_one_input_for_number(choice, " ",
                                               "What's your choice?")

    while choice != 0:
        if choice == 1:
            ui.print_result(get_the_last_buyer_name(),
                            "The latest buyer name: ")

        elif choice == 2:
            ui.print_result(get_the_last_buyer_id(), "Last buyer's ID: ")

        elif choice == 3:
            ui.print_result(
                get_the_buyer_name_spent_most_and_the_money_spent(),
                "The buyer name is: ")

        elif choice == 4:
            ui.print_result(get_the_buyer_id_spent_most_and_the_money_spent(),
                            "The buyer's ID is: ")

        elif choice == 5:
            ui.print_result(get_the_most_frequent_buyers_names(),
                            "The most frequent buyers names: ")

        elif choice == 6:
            ui.print_result(get_the_most_frequent_buyers_ids(),
                            "The most frequent buyers IDs: ")

        elif choice == 7:
            ui.print_result(customer_without_purchase(), "The customers: ")

        else:
            ui.print_error_message("Wrong input!")

        ui.print_menu("Data Analyser MENU", special_functions,
                      "go back to Main Menu.")
        choice = ui.get_inputs(" ", "What's your choice?")
        choice = common.check_one_input_for_number(choice, " ",
                                                   "What's your choice?")
        common.clear()

    common.clear()
示例#22
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions = [
        "Show table", "Add elements", "Remove element by it's ID",
        "Update an element", "Get lowest price ID",
        "Get items sold between two dates"
    ]

    table = data_manager.get_table_from_file("sales/sales_test.csv")
    ui.print_menu("Sales Manager MENU", special_functions, "")
    choice = ui.get_inputs(" ", "What's your choice?")
    choice = common.check_one_input_for_number(choice, " ",
                                               "What's your choice?")

    while choice != 0:
        if choice == 1:  #show, choice[0] because from the user inputs we get lists
            show_table(table)

        elif choice == 2:  #add
            add(table)
            data_manager.write_table_to_file("sales/sales_test.csv", table)

        elif choice == 3:  #remove
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            remove(table, id)
            data_manager.write_table_to_file("sales/sales_test.csv", table)

        elif choice == 4:  #update
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            update(table, id)
            data_manager.write_table_to_file("sales/sales_test.csv", table)

        elif choice == 5:  #lowest price item id
            ui.print_result(
                get_lowest_price_item_id(table),
                "The ID of the item that was sold for the lowest price is:")

        elif choice == 6:  #avg
            list = ["year", "month", "day"]
            date1 = []
            date2 = []
            for i in range(3):
                value = int(
                    ui.get_inputs(" ", "Add the first date's {}".format(
                        list[i]))[0])

                if i == 0:  # years
                    while not (value > 0):

                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the first date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the first date's {}".format(list[i]))
                    date1.append(value)

                elif i == 1:  #months
                    while not (value > 0) or not (value < 13):
                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the first date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the first date's {}".format(list[i]))
                    date1.append(value)

                elif i == 2:  # days
                    if common.leap_year_checker(date1[0]) is True:
                        month_to_day[2] = 29
                    while not (value > 0) or not (value <=
                                                  month_to_day[date1[1]]):
                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the first date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the first date's {}".format(list[i]))
                    date1.append(value)
                    month_to_day[2] = 28
            for i in range(3):
                value = ui.get_inputs(
                    " ", "Add the second date's {}".format(list[i]))
                value = common.check_one_input_for_number(
                    value, " ", "Add the second date's {}".format(list[i]))
                if i == 0:
                    while not (value > 0):

                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the second date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the second date's {}".format(list[i]))
                    date2.append(value)

                elif i == 1:
                    while not (value > 0) or not (value < 13):
                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the second date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the second date's {}".format(list[i]))
                    date2.append(value)

                elif i == 2:
                    if common.leap_year_checker(int(date2[0])) == True:
                        month_to_day[2] = 29
                    while not (value > 0) or not (value <=
                                                  month_to_day[date1[1]]):
                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the second date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the second date's {}".format(list[i]))

                    date2.append(value)
                    month_to_day[2] = 28
            result = get_items_sold_between(table, date1[1], date1[2],
                                            date1[0], date2[1], date2[2],
                                            date2[0])

            ui.print_result(result,
                            "These items are sold between the given dates:")

        else:
            ui.print_error_message("Wrong input!")

        ui.print_menu("Sales Manager MENU", special_functions, "")
        choice = ui.get_inputs(" ", "What's your choice?")
        choice = common.check_one_input_for_number(choice, " ",
                                                   "What's your choice?")
        common.clear()

    common.clear()
示例#23
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions = [
        "Show table", "Add elements", "Remove element by it's ID",
        "Update an element",
        "Get which items have not exceeded their durability yet",
        "Get the average durability times for each manufacturer"
    ]

    table = data_manager.get_table_from_file("inventory/inventory_test.csv")
    ui.print_menu("Inventory Manager MENU", special_functions,
                  "go back to Main Menu.")
    choice = ui.get_inputs(" ", "What's your choice?")
    choice = common.check_one_input_for_number(choice, " ",
                                               "What's your choice?")

    while choice != 0:
        if choice == 1:  #show, choice[0] because from the user inputs we get lists
            show_table(table)

        elif choice == 2:  #add
            add(table)
            data_manager.write_table_to_file("inventory/inventory_test.csv",
                                             table)

        elif choice == 3:  #remove
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            remove(table, id)
            data_manager.write_table_to_file("inventory/inventory_test.csv",
                                             table)

        elif choice == 4:  #update
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            update(table, id)
            data_manager.write_table_to_file("inventory/inventory_test.csv",
                                             table)

        elif choice == 5:  #exceeded
            year = ui.get_inputs(" ", "Give the year")
            year = common.check_one_input_for_number(year, " ",
                                                     "Give the year")
            ui.print_result(
                get_available_items(table, year),
                "These items that not exceeded their durability yet:")

        elif choice == 6:  #manufactures avg
            result = get_average_durability_by_manufacturers(table)
            ui.print_result(
                result,
                "The average durability times for each manufaturer is:")

        else:
            ui.print_error_message("Wrong input!")

        ui.print_menu("Inventory Manager MENU", special_functions,
                      "go back to Main Menu.")
        choice = ui.get_inputs(" ", "What's your choice?")
        choice = common.check_one_input_for_number(choice, " ",
                                                   "What's your choice?")
        common.clear()

    common.clear()