def constructJobList(self):
        jobList = JobList()
        for day in self.statData:
            for segment in day:
                # Choose the segment based off of the job flow rate
                activeSegment = self.segmentSelector(segment)
                
                for data in activeSegment:
                    delayReason = data.get("DelayReason")
                    delayTime = data.get("DelayMin")
                    
                    if not delayTime:
                        delayTime = 0
                        
                    # Convert delay time to seconds from minutes
                    delayTime = int(delayTime) * 60
                    
                    pendingTimeAbs = self.strToS(data["PendingDT"])
                    # Convert the absolute values to delta values based off of the previous state
                    inProgressTimeDelta = strToT(data["InProgressDT"]) - strToT(data["DispatchedDT"])
                    completeTimeDelta = strToT(data["CompleteDT"]) - strToT(data["InProgressDT"])
                        
                    origin = data["Origin"]
                    destination = data["Destination"]
                    priority = int(data["OriginalPriorityID"])
                    appointment = 1 if data["Created_Status"] == "Appointment" else 0

                    jobList.insert(Job(pendingTimeAbs, inProgressTimeDelta, completeTimeDelta, origin, destination, priority, appointment, delayReason, delayTime))
                    
        return jobList
Beispiel #2
0
    def select_action(self):
        return random.choice(self.actions)

    def begin_game(self):
        play = True

        while play is True:
            like = input("Would you like to play a turn? y/n ")
            if like == 'y':
                action = self.select_action()
                print(action)
                if action == "home":
                    house.choose_house()
                elif action == "job":
                    self.player.money += self.joblist.select_job()
                else:
                    self.player.add_kid(1000)
            else:
                print("It was nice playing with you!")
                self.player.print_attributes()


if __name__ == "__main__":
    player1 = Person()
    player1.get_name()

    house = House()
    job_list = JobList()

    game_board = Board(player1, job_list, house)
    game_board.begin_game()
Beispiel #3
0
def main():
    """execute qstat and produces output according to chosen options."""

    from datetime import datetime
    from subprocess import Popen, PIPE
    import xml.etree.ElementTree as ET

    import cmdargs
    import configfile
    import constants
    from job import Job, JobList, JobGroup

    args = cmdargs.parse()
    if args.edit_interactive:
        print(constants.path_config+':\n')
        print('option: current value (default)> enter new value')
        print('empty string to keep current value')
        print('single x to set to default value')
        print('trailing spaces to set to an actual x/empty string', end='\n\n')
        args = vars(args)
        for opt, dflt_val in constants.default_config.items():
            new_val = input('{}: {} ({})> '.format(opt, args[opt], dflt_val))
            if new_val:
                if new_val == 'x':
                    args[opt] = dflt_val
                else:
                    args[opt] = new_val

        if not str(args['width_tot']).isdigit():
            args['width_tot'] = constants.default_config['width_tot']

        configfile.write(args, constants.path_config)
        sys.exit()

    if args.items:
        print(*('{}: {}'.format(k, v.dscr) for k, v in constants.itms.items()),
              sep='\n')
        sys.exit()

    if args.file:
        qstat_out = args.file
    else:
        qstat_out = Popen(args.qstat_cmd +
                          ' -u "' + args.users + '" -xml -r',
                          shell=True, stdout=PIPE).stdout

    qstat_out = ET.parse(qstat_out).getroot().iter('job_list')

    alljobs = []
    today = datetime.today()
    for j in qstat_out:
        alljobs.append(Job(j, args, today))

    if not alljobs:
        if not args.mute:
            print('No pending or running job.')
    else:
        alljobs = JobList(alljobs, args)

        out_gen = (alljobs.rep(), alljobs.rep_tot())
        for line in out_gen[args.reverse]:
            print(line)

        if args.out and args.total:
            print()

        for line in out_gen[not args.reverse]:
            print(line)