示例#1
0
def generate(argv):
   optlist, fixtures = getOpt(longOpts, argv)

   target = None
   inputEncoding = 'utf-8'
   encoding = 'utf-8'

   for o, a in optlist:
      if o == "-o":
         target = a
      elif o == "-i":
         inputEncoding = a
      elif o == "-e":
         encoding = a

   if target == None:
      usage(longOpts)
      sys.exit(1)

   absFixtures = []
   for fixture in fixtures:
      if os.path.isabs(fixture):
         absFixtures.append(fixture)
      else:
         absFixtures.append(os.path.join(os.getcwd(), fixture))

   process(target, absFixtures, inputEncoding, encoding)
示例#2
0
def generate(argv):
    optlist, fixtures = getOpt(longOpts, argv)

    target = None

    encoding = 'utf-8'

    target_dir = None

    for o, a in optlist:
        if o == "-o":
            target = a
        elif o == "-e":
            encoding = a
        elif o == "-d":
            target_dir = a

    inputEncoding = encoding

    if target_dir != None:
        if not os.path.exists(target_dir):
            os.makedirs(target_dir)
        while (fixtures != []):
            fixture = fixtures.pop()
            absFixtures = []
            h_file_path = fixture
            if not os.path.isabs(fixture):
                h_file_path = os.path.join(os.getcwd(), fixture)
            absFixtures.append(h_file_path)
            h_file = os.path.basename(fixture)
            cpp_file = h_file.replace('.h', '.cpp')

            theEnd = (fixtures == [])
            if cpp_file == '':
                continue
            cpp_file_path = processEndFile(target_dir, cpp_file, theEnd)

            if newerThan(cpp_file_path, h_file_path) and (not theEnd):
                Output.output = Output.output2null  # output nothing, but record fixtureDescs.
            else:
                Output.output = Output.output2file

            process(cpp_file_path, absFixtures, inputEncoding, encoding,
                    not theEnd)
        return

    if target == None:
        usage()
        sys.exit(1)

    absFixtures = []
    for fixture in fixtures:
        if os.path.isabs(fixture):
            absFixtures.append(fixture)
        else:
            absFixtures.append(os.path.join(os.getcwd(), fixture))

    process(target, absFixtures, inputEncoding, encoding)
示例#3
0
def generate(argv):
   optlist, fixtures = getOpt(longOpts, argv)

   target = None

   encoding = 'utf-8'

   target_dir = None

   for o, a in optlist:
      if o == "-o":
         target = a
      elif o == "-e":
         encoding = a
      elif o == "-d":
	     target_dir = a

   inputEncoding = encoding

   if target_dir != None:
      if not os.path.exists(target_dir) :
         os.makedirs(target_dir)
      while (fixtures != []) :
         fixture = fixtures.pop()
         absFixtures = []
         h_file_path=fixture
         if not os.path.isabs(fixture):
            h_file_path = os.path.join(os.getcwd(), fixture)
         absFixtures.append(h_file_path)
         h_file = os.path.basename(fixture)
         cpp_file = h_file.replace('.h', '.cpp')

         theEnd = (fixtures == [])
         if cpp_file == '':
             continue
         cpp_file_path = processEndFile(target_dir, cpp_file, theEnd)

         if newerThan(cpp_file_path, h_file_path) and (not theEnd):
            Output.output = Output.output2null   # output nothing, but record fixtureDescs.
         else :
            Output.output = Output.output2file

         process(cpp_file_path, absFixtures, inputEncoding, encoding, not theEnd)
      return

   if target == None:
      usage()
      sys.exit(1)

   absFixtures = []
   for fixture in fixtures:
      if os.path.isabs(fixture):
         absFixtures.append(fixture)
      else:
         absFixtures.append(os.path.join(os.getcwd(), fixture))

   process(target, absFixtures, inputEncoding, encoding)
示例#4
0
 def add(self):
     rowPosition = self.tableWidget.rowCount()
     name = self.p_name.text()
     if name == "":
         self.show_popup("Process name cannot be empty")
         return None
     try:
         arrival = int(self.p_arrival.text())
         burst = int(self.p_burst.text())
     except:
         self.show_popup("Arrival time and Burst time should be integers")
         return None
     if arrival < 0:
         self.show_popup("Arrival should be more than or equal zero")
         return None
     if burst <= 0:
         self.show_popup("Burst should be more than zero")
         return None
     if name in self.process_dic:
         self.show_popup("Process already exists")
         return None
     self.process_dic[name] = process(int(arrival), int(burst))
     self.tableWidget.insertRow(rowPosition)
     self.tableWidget.setItem(rowPosition, 0,
                              QtWidgets.QTableWidgetItem("{}".format(name)))
     self.tableWidget.setItem(
         rowPosition, 1, QtWidgets.QTableWidgetItem("{}".format(arrival)))
     self.tableWidget.setItem(
         rowPosition, 2, QtWidgets.QTableWidgetItem("{}".format(burst)))
 def setSegmentsAndAlgorithms(self, numberOfSegments, Algorithm):
     if Algorithm == 'firstFit':
         self.__firstFitFlag = 1
     else:
         self.__firstFitFlag = 0
     proc = process('P' + str(len(self.__listOfAllProcesses)), 'waiting',
                    numberOfSegments)
     self.__listOfAllProcesses.append(proc)
示例#6
0
class element:
    p = process()
    start = 0.0
    end = 0.0
    duration = 0.0

    def __repr__(self):
        return 'process name: %s start: %s end: %s' % (
            self.p.name, str(self.start), str(self.end))
示例#7
0
 def get_info(event):
     P = process()
     P.name = "p" + str(i + 1)
     P.burst_time = float(bt_entry.get())
     P.arrival_time = float(at_entry.get())
     at_entry.delete(0, END)
     bt_entry.delete(0, END)
     if s == "priority":
         P.pr = int(pr_entry.get())
         pr_entry.delete(0, END)
     list_of_process.append(P)
示例#8
0
 def srtf_clicked(self):
     if len(self.process_dic) == 0:
         self.show_popup("There is no Processes")
         return None
     input_SRTF = dict()
     for i in self.process_dic:
         input_SRTF[i] = process(self.process_dic[i].getArrival(),
                                 self.process_dic[i].getBurst())
     result = main.SRTF(
         dict(sorted(input_SRTF.items(), key=lambda x: x[1].getArrival())))
     main.printAlgo(result)
     self.avg_w.display(main.avgWaiting(result))
     self.avg_t.display(main.avgTurnAround(result))
示例#9
0
 def get_info(event):
     global ii
     P = process()
     P.name = "p" + str(ii + 1)
     P.burst_time = float(bt_entry.get())
     P.arrival_time = float(at_entry.get())
     at_entry.delete(0, END)
     bt_entry.delete(0, END)
     if s == "priority":
         P.pr=int(pr_entry.get())
         pr_entry.delete(0,END)
     list_of_process.append(P)
     down_frame.pack_forget()
     down_frame.destroy()
     ii=ii+1
     if ii<n :show(ii)
示例#10
0
def processCMD(cmdStr):
    #Split command string into components
    words = cmdStr.split(" ")

    #Print line for user friendly output
    outputText.insert(
        tk.INSERT, "======================================================\n")

    #Process Termination Sequence
    if words[1] == '-1\n' or words[1] == '-1':
        #Print input commands
        output = 'PID: ' + words[0] + ' Terminates\n'
        intext = words[0] + " " + words[1]

        inputText.insert(tk.INSERT, intext)
        outputText.insert(tk.INSERT, output)

        #Remove process = PID from process queue and reallocate memory
        ram.removeProcess(int(words[0]))
    else:  #Process Loading Sequence
        #Print out cmd string components
        intext = words[0] + " " + words[1] + " " + words[2]
        output = 'PID: ' + words[0] + ' arrives: ' + '\tCode/Text: ' + words[
            1] + '\tData: ' + words[2]

        inputText.insert(tk.INSERT, intext)
        outputText.insert(tk.INSERT, output)

        #Convert input string into usable int values
        PID = int(words[0])
        dataSIZE = int(words[2])
        codeSIZE = int(words[1])

        #Create Processes
        x = process(dataSIZE, codeSIZE, PID, 512)

        #Allocate Memory
        if ram.loadProcess(x):
            x.printPageTables(display=outputText)
        else:
            print("Load Failed")
            x.printPageTables(display=outputText)

    ram.printMemoryTable(display=outputText)

    outputText.insert(tk.INSERT, "\n\n")
示例#11
0
    def runProcess(self):
        """
        This function runs the whole process writing the requested outputs in the project's output folder.
        :return: write 5 dataframes
        """
        try:
            sc = SparkContext(master='local', appName='Developer_Challenge')
            spark = SQLContext(sc)

            # Class Declaration
            read_data = input(spark)
            process_data = process(spark)
            write = output(spark)

            # Read data
            df: DataFrame = read_data.readData()

            # Process the data
            data = process_data.splitDataFrame(df)
            data = process_data.renameColumns(data)

            data.persist()

            # Write by nationality
            write.writeByNationality(data)

            # the 10 top players for each position (OVA)
            top_ply_ova = process_data.topPlayersOVA(data)
            write.writeTopOVA(top_ply_ova)

            # How many players for each position have each Club
            ply_by_club_pos = process_data.countPlayerPosClub(data)
            write.writeDF(ply_by_club_pos, output_path_ply_by_club_pos)

            # top 10 clubs for sprint speed average
            top_spr_spd_avg = process_data.topSprintSpeedAverage(data)
            write.writeDF(top_spr_spd_avg, output_path_top_spr_spd_avg)

            # All players with overweight (IMC>25)
            ply_overweight = process_data.calculateIMC(data)
            write.writeDF(ply_overweight, output_path_ply_overweight)

        except Exception as ex:
            print(ex)
示例#12
0
 def rr_clicked(self):
     if self.q.text() == "":
         self.show_popup("Q cannot be empty")
         return None
     try:
         q = int(self.q.text())
     except:
         self.show_popup("Q should be integer")
         return None
     if q <= 0:
         self.show_popup("Q should be more than zero")
         return None
     if len(self.process_dic) == 0:
         self.show_popup("There is no Processes")
         return None
     input_RR = dict()
     for i in self.process_dic:
         input_RR[i] = process(self.process_dic[i].getArrival(),
                               self.process_dic[i].getBurst())
     result = main.RR(
         dict(sorted(input_RR.items(), key=lambda x: x[1].getArrival())), q)
     main.printAlgo(result)
     self.avg_w.display(main.avgWaiting(result))
     self.avg_t.display(main.avgTurnAround(result))
示例#13
0
from Process import process
from Priority import priority
p1 = process()
p2 = process()
p3 = process()
p4 = process()
p5 = process()
#p6=process()
#p7=process()
p1.burst_time = 4
p2.burst_time = 10
p3.burst_time = 2
p4.burst_time = 20
p5.burst_time = 2
#p6.burst_time=15
#7.burst_time=8
p1.arrival_time = 0
p2.arrival_time = 2
p3.arrival_time = 4
p4.arrival_time = 6
p5.arrival_time = 8
#p6.arrival_time=5
#p7.arrival_time=15
p1.pr = 4
p2.pr = 2
p3.pr = 1
p4.pr = 3
p5.pr = 5
#p6.pr=10
#p7.pr=9
p1.name = 'p1'
示例#14
0
        # try:
        #############################输入使用的模型位置和名
        model = input("model: \n")
        ######################输入待分析的网络流数据集的位置和文件名
        data = input("data: \n")

        try:
            print("Running!Please wait and donnot do anything!\n")

            net.load_state_dict(torch.load(model, map_location=lambda storage,loc:storage))

            dataset = inputDataSet(data)
            data_loader = DataLoader(dataset, batch_size=batch_size)

            #########输入网络模型,,未知协议识别最高置信率阈值,,结果输出的位置和文件名
            label_list = process(net,data_loader, 0.97 )

            #***********************************************************************************************************************************

            unknow_data = pandas.DataFrame()

            ##############################输入未知协议的网络流数据集的文件位置和名
            inputData = pandas.read_csv(data, index_col=None)

            longlong = len(label_list)
            origin_to_new = numpy.zeros((longlong,2),dtype=int)
            num_unknow_data =0
            for i in range(longlong):
                if label_list[i] == 404:
                    origin_to_new[num_unknow_data,0] = i
                    num_unknow_data+=1
示例#15
0
from SJF import Sjf
from Fcfs import fcfs
from Process import process
import random

test=Sjf()
pro=[]


for i in range (6):
    a=process()
    pro.append(a)
    pro[i].name='p'+str(i+1)
#pro[0].burst_time,pro[1].burst_time,pro[2].burst_time= 1,3,1
#pro[0].arrival_time,pro[1].arrival_time,pro[2].arrival_time= 0,1,2
pro[0].burst_time,pro[1].burst_time,pro[2].burst_time,pro[3].burst_time,pro[4].burst_time,pro[5].burst_time= 1.5,2,1,15,17,20
pro[0].arrival_time,pro[1].arrival_time,pro[2].arrival_time,pro[3].arrival_time,pro[4].arrival_time,pro[5].arrival_time= 0,1,2,5,6,7
#pro[0].pr,pro[1].pr,pro[2].pr,pro[3].pr,pro[4].pr,pro[5].pr=5,4,3,2,1,0
test.preemptive=1
test.list_process=pro
test.real()
test.calc()
waiting=test.waiting_time()
test.empty()
for i in range(len(test.list_element)):

    print(test.list_element[i])
print ('waiting time = %s'%(waiting))
#,pro[4].burst_time,pro[5].burst_time 0,1,2,3,4,5         8,4,2,1,3,2 , 1.5,2,1,15,17,20
#,pro[4].arrival_time,pro[5].arrival_time
示例#16
0
from Process import process
from Priority import priority
p1 = process()
p2 = process()
p3 = process()
p4 = process()
p5 = process()
p6 = process()
p7 = process()
p8 = process()

p1.burst_time = 4
p2.burst_time = 2
p3.burst_time = 3
p4.burst_time = 5
p5.burst_time = 1
p6.burst_time = 4
p7.burst_time = 6
p8.burst_time = 10

p1.arrival_time = 0
p2.arrival_time = 1
p3.arrival_time = 2
p4.arrival_time = 3
p5.arrival_time = 4
p6.arrival_time = 5
p7.arrival_time = 6
p8.arrival_time = 30

p1.pr = 12
p2.pr = 10
示例#17
0
# upper = np.array([150,255,255])

lower = np.array([10, 40, 80])
upper = np.array([100, 250, 250])

mask = cv2.inRange(blurr, lower, upper)

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

cv = cv2.bitwise_and(gray, mask)
cv2.imshow('maks', mask)
t1, th1 = cv2.threshold(gray, 110, 255, cv2.THRESH_BINARY_INV)

t, thresh = cv2.threshold(mask, 110, 255, cv2.THRESH_BINARY)

cnts, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

cv2.drawContours(image, cnts, -1, (0, 255, 0), 1)

# for cnt in cnts:
# 	print(cnt)
# 	cntarea = cv2.contourArea(cnt)
# 	if cntarea > 0 :
# 		print(cntarea)
# 		cv2.drawContours(image,cnt,-1,(0,255,0),1)

process(cnts)

cv2.imshow('Res', image)

cv2.waitKey(0)
示例#18
0
from Fcfs import fcfs
from Process import process

A = process()
B = process()
C = process()
D = process()
E = process()
#F=process()

A.burst_time = 5
B.burst_time = 3
C.burst_time = 1
D.burst_time = 2
E.burst_time = 3
#F.burst_time=3

A.arrival_time = 0
B.arrival_time = 1
C.arrival_time = 2
D.arrival_time = 3
E.arrival_time = 4
#F.arrival_time=6

A.name = 'p1'
B.name = 'p2'
C.name = 'p3'
D.name = 'p4'
E.name = 'p5'
#F.name='p6'
示例#19
0
# In[14]:
ProcessFile = {'Desk': [{'Name': 'FundOver', 'Process': []}]}
#ProcessFile={'Desk':[]}

with open(
        f'Z:\\Fund_Oversight\\OVERSIGHT\\Operations\\Tools\\Scheduler\\Processes.json',
        'w') as outfile:
    json.dump(ProcessFile, outfile, indent=4, separators=(',', ': '))

# In[14]:
inputs = []

p = process(
    path='Z:\\Fund_Oversight\\OVERSIGHT\\Operations\\Tools\\Processes\\',
    name='Errorlog',
    hour=25,
    RelativeDayStr='SD')
p.RemoveProcess()
#p.CreateNew()

# In[14]:
inputs = []

p = process(
    path='Z:\\Fund_Oversight\\OVERSIGHT\\Operations\\Tools\\Processes\\',
    name='FileGrab',
    Frequency=0.5,
    RelativeDayStr='SD')
p.RemoveProcess()
p.CreateNew()
示例#20
0
def start():
    while True:
        print("Menu:")
        print("1) FCFS ")
        print("2) SJF ")
        print("3) SRTF ")
        print("4) RR ")
        print("5) all of them")
        print("0) quit ")
        choice = ""
        while not isinstance(choice, int):
            choice = input("enter your choice:")
            try:
                choice = int(choice)
                if choice < 0 or choice > 5:
                    choice = ""
            except:
                choice = ""
        if choice == 0:
            break
        input_FCFS = dict()
        input_SJF = dict()
        input_SRTF = dict()
        input_RR = dict()
        num = ""
        while not isinstance(num, int):
            num = input("enter the number of processes :")
            try:
                num = int(num)
                if num <= 0:
                    num = ""
            except:
                num = ""
        for i in range(int(num)):
            arrival = ""
            burst = ""
            while not isinstance(arrival, int):
                arrival = input(
                    "enter process {0} (P{0}) arrival time:".format(i + 1))
                try:
                    arrival = int(arrival)
                    if arrival < 0:
                        arrival = ""
                except:
                    arrival = ""
            while not isinstance(burst, int):
                burst = input("enter process {0} (P{0}) burst time:".format(i +
                                                                            1))
                try:
                    burst = int(burst)
                    if burst <= 0:
                        burst = ""
                except:
                    burst = ""
            input_FCFS["P" + str(i + 1)] = process(int(arrival), int(burst))
            input_SJF["P" + str(i + 1)] = process(int(arrival), int(burst))
            input_SRTF["P" + str(i + 1)] = process(int(arrival), int(burst))
            input_RR["P" + str(i + 1)] = process(int(arrival), int(burst))
        if choice == 1:
            print("================================================")
            print("FCFS :")
            printAlgo(
                FCFS(
                    dict(
                        sorted(input_FCFS.items(),
                               key=lambda x: x[1].getArrival()))))
            print("================================================")
            input("Press any key to continue")
        elif choice == 2:
            print("================================================")
            print("SJF :")
            printAlgo(
                SJF(
                    dict(
                        sorted(input_SJF.items(),
                               key=lambda x: x[1].getArrival()))))
            print("================================================")
            input("Press any key to continue")
        elif choice == 3:
            print("================================================")
            print("SRTF :")
            printAlgo(
                SRTF(
                    dict(
                        sorted(input_SRTF.items(),
                               key=lambda x: x[1].getArrival()))))
            print("================================================")
            input("Press any key to continue")
        elif choice == 4:
            q = ""
            while not isinstance(q, int):
                q = input("enter Q :")
                try:
                    q = int(q)
                    if q <= 0:
                        q = ""
                except:
                    q = ""
            print("================================================")
            print("RR , Q = {0}:".format(q))
            printAlgo(
                RR(
                    dict(
                        sorted(input_RR.items(),
                               key=lambda x: x[1].getArrival())), q))
            print("================================================")
            input("Press any key to continue")
        elif choice == 5:
            q = ""
            while not isinstance(q, int):
                q = input("enter Q for RR :")
                try:
                    q = int(q)
                    if q <= 0:
                        q = ""
                except:
                    q = ""
            print("================================================")
            print("FCFS :")
            printAlgo(
                FCFS(
                    dict(
                        sorted(input_FCFS.items(),
                               key=lambda x: x[1].getArrival()))))
            print("================================================")
            print("SJF :")
            printAlgo(
                SJF(
                    dict(
                        sorted(input_SJF.items(),
                               key=lambda x: x[1].getArrival()))))
            print("================================================")
            print("SRTF :")
            printAlgo(
                SRTF(
                    dict(
                        sorted(input_SRTF.items(),
                               key=lambda x: x[1].getArrival()))))
            print("================================================")
            print("RR , Q = {0}:".format(q))
            printAlgo(
                RR(
                    dict(
                        sorted(input_RR.items(),
                               key=lambda x: x[1].getArrival())), q))
            print("================================================")
            input("Press any key to continue")