예제 #1
0
def case_run(request):
    if request.method == 'POST':
        case_id = request.POST['case_id']
        env_id = request.POST['env_id']
        execute = Execute(case_id, env_id)
        case_result = execute.run_case()
        return JsonResponse(case_result)
예제 #2
0
파일: listen.py 프로젝트: DavidGDragon/cds
    def handle_message_callback(self, message, is_redelivered=True):
        self.log.info('Message callback invoked: {0}'.format(is_redelivered))
        response = {'success': True}
        try:
            self.execute = Execute(message)

            if self.execute.container_name != self.config['CONTAINER_NAME']:
                error_message = 'Invalid DS message received. ' \
                    'Unmatched container names. \n CONFIG: {0}' \
                    '\nCONTAINER_NAME {1}'.format(
                        self.config, self.execute.container_name)
                self.log.error(error_message)
                response['success'] = False
                response['error'] = error_message
                raise Exception(error_message)
            else:
                self.log.info('Valid DS message : {0}'.format(
                    self.config['BOOT_SUCCESS_MESSAGE']))
                self.log.info(self.execute.message)

                # this is read by HDQ to decide whether DS container
                # boot was successful or not
                print self.config['BOOT_SUCCESS_MESSAGE']
                boot_file = open('/home/shippable/bootinfo.txt', 'a')
                boot_file.write('success')
                boot_file.close()
                sys.stdout.flush()

            self.execute.run()
        except Exception as exc:
            self.log.error(str(exc))
            trace = traceback.format_exc()
            self.log.debug(trace)
        return response
예제 #3
0
파일: listen.py 프로젝트: rageshkrishna/cds
class Listen(Base):
    def __init__(self):
        Base.__init__(self, __name__)
        self.log.info('Inside DS listener')
        self.message_reader = MessageReader(
            self, self.config["VHOST_AMQP_URL"],
            self.config['LISTEN_QUEUE'],
            self.config['DEFAULT_EXCHANGE'])

        self.itinerary = None
        self.execute = None
        self.log.info('Boot successful')

    def main(self):
        self.log.info('inside Listen main')
        try:
            self.message_reader.connect_and_read(self.handle_message_callback)
        except Exception as exc:
            self.log.error('Error starting listener - {0}'.format(exc))
        finally:
            self.log.debug('Cleaning up the listener')
            handlers = self.log.handlers[:]
            for handler in handlers:
                handler.close()
                self.log.remove_handler(handler)
            print 'STOP_TAILING'
            sys.stdout.flush()
            
    def handle_message_callback(self, message, is_redelivered=True):
        self.log.info('Message callback invoked: {0}'.format(is_redelivered))
        response = {'success': True}
        try:
            self.execute = Execute(message)

            if self.execute.container_name != self.config['CONTAINER_NAME']:
                error_message = 'Invalid DS message received. ' \
                    'Unmatched container names. \n CONFIG: {0}' \
                    '\nCONTAINER_NAME {1}'.format(
                        self.config, self.execute.container_name)
                self.log.error(error_message)
                response['success'] = False
                response['error'] = error_message
                raise Exception(error_message)
            else:
                self.log.info('Valid DS message : {0}'.format(
                    self.config['BOOT_SUCCESS_MESSAGE']))
                self.log.info(self.execute.message)

                # this is read by HDQ to decide whether DS container
                # boot was successful or not
                print self.config['BOOT_SUCCESS_MESSAGE']
                sys.stdout.flush()

            self.execute.run()
        except Exception as exc:
            self.log.error(str(exc))
            trace = traceback.format_exc()
            self.log.debug(trace)
        return response
예제 #4
0
class Listen(Base):
    def __init__(self):
        Base.__init__(self, __name__)
        self.log.info('Inside DS listener')
        self.message_reader = MessageReader(self,
                                            self.config["VHOST_AMQP_URL"],
                                            self.config['LISTEN_QUEUE'],
                                            self.config['DEFAULT_EXCHANGE'])

        self.itinerary = None
        self.execute = None
        self.log.info('Boot successful')

    def main(self):
        self.log.info('inside Listen main')
        try:
            self.message_reader.connect_and_read(self.handle_message_callback)
        except Exception as exc:
            self.log.error('Error starting listener - {0}'.format(exc))
        finally:
            self.log.debug('Cleaning up the listener')
            handlers = self.log.handlers[:]
            for handler in handlers:
                handler.close()
                self.log.remove_handler(handler)
            print 'STOP_TAILING'
            sys.stdout.flush()

    def handle_message_callback(self, message, is_redelivered=True):
        self.log.info('Message callback invoked: {0}'.format(is_redelivered))
        response = {'success': True}
        try:
            self.execute = Execute(message)

            if self.execute.container_name != self.config['CONTAINER_NAME']:
                error_message = 'Invalid DS message received. ' \
                    'Unmatched container names. \n CONFIG: {0}' \
                    '\nCONTAINER_NAME {1}'.format(
                        self.config, self.execute.container_name)
                self.log.error(error_message)
                response['success'] = False
                response['error'] = error_message
                raise Exception(error_message)
            else:
                self.log.info('Valid DS message : {0}'.format(
                    self.config['BOOT_SUCCESS_MESSAGE']))
                self.log.info(self.execute.message)

                # this is read by HDQ to decide whether DS container
                # boot was successful or not
                print self.config['BOOT_SUCCESS_MESSAGE']
                sys.stdout.flush()

            self.execute.run()
        except Exception as exc:
            self.log.error(str(exc))
            trace = traceback.format_exc()
            self.log.debug(trace)
        return response
예제 #5
0
 def sup_check(self):
     if self.mid < self.dfD.iloc[-1]['Daily Pivot Point']:
         print '**** Checking Support Pivots ****'
         sup = Support(self.instrument, self.mid, self.dfD, self.units,
                       self.pivot, self.sl1, self.sl2, self.sl3, self.rate1,
                       self.rate2)
         print sup.support()
         try:
             supUnits, supProfit, supLoss = sup.support()
             supex = Execute(self.api, self._id, self.instrument, supUnits,
                             supProfit, supLoss)
             supex.trade()
         except Exception as e:
             print(e)
예제 #6
0
 def res_check(self):
     if self.mid > self.dfD.iloc[-1]['Daily Pivot Point']:
         print '**** Checking Resistance Pivots ****'
         res = Resistance(self.instrument, self.mid, self.dfD, self.units,
                          self.pivot, self.rl1, self.rl2, self.rl3,
                          self.rate1, self.rate2)
         print res.resistance()
         try:
             resUnits, resProfit, resLoss = res.resistance()
             resex = Execute(self.api, self._id, self.instrument, resUnits,
                             resProfit, resLoss)
             resex.trade()
         except Exception as e:
             print(e)
예제 #7
0
파일: mark.py 프로젝트: aluckyi/MarkGT
    def __init__(self):
        super().__init__()

        self.exe = Execute()
        self.img_lbl.initXYBoxObjs(self.x_box, self.y_box)
        self.img_lbl.initReferLineNumObj(self.ref_num_lbl)
        self.img_lbl.initHorizonModifyObj(self.horizon_modify_btn)
        self.img_lbl.initSLObsNumObjs(self.small_obs_num_lbl, self.large_obs_num_lbl)

        self.start_flag = False
        self.mode = 'Horizon'
        self.horizon_method = 'Manual'
        self.refer_lines_flag = False
        self.obs_cls = 'Small Obstacle'
예제 #8
0
 def __init__(self, main):
     """
     Parent constructor call,
     call setup for gui, 
     create thread object for 
     the script and connect signals
     to slots
     """
     super(Gui_Main, self).__init__()
     self.setupUi(main)
     self.execute = Execute()
     self.connect(self.execute, SIGNAL("setOutput(QString)"),
                  self.setOutput)
     self.connect(self.execute, SIGNAL("finished(bool)"), self.finished)
     self.step = 0
예제 #9
0
파일: fuzzer.py 프로젝트: doduytrung/XDiFF
	def fuzz(self, tests):
		"""Executes something in all the different pieces of software"""
		process = []		# info to be return and saved in the database
		# go through each test
		for test in tests:
			for piece in self.settings['software']:
				input = self.get_input(piece, test)
				try:
					process.append(Execute(self.settings, piece, input))
				except Exception:
					print "Error when trying to append a new process. Try using less parallel threads. Terminating..."
					sys.exit()
		for x in range(0, len(process)):
			process[x].join()
		for x in range(0, len(process)):
			process[x] = process[x].get_output()
		# save the network results
		if self.ids:
			for x in range(0, len(self.ids)):
				for z in range(0, len(process)):
					if process[z]['testcaseid'] == self.ids[x][0] and process[z]['softwareid'] == self.ids[x][1]:
						process[z]['network'] = self.ids[x][2]
						break
			self.ids = []
		self.settings['logger'].debug("Process: %s" % str(process))
		return process
예제 #10
0
파일: listen.py 프로젝트: ragsden/cds
    def handle_message_callback(self, message, is_redelivered=True):
        self.log.info('Message callback invoked: {0}'.format(is_redelivered))
        response = {'success': True}
        try:
            self.execute = Execute(message)

            if self.execute.container_name != self.config['CONTAINER_NAME']:
                error_message = 'Invalid DS message received. ' \
                    'Unmatched container names. \n CONFIG: {0}' \
                    '\nCONTAINER_NAME {1}'.format(
                        self.config, self.execute.container_name)
                self.log.error(error_message)
                response['success'] = False
                response['error'] = error_message
                raise Exception(error_message)
            else:
                self.log.info('Valid DS message : {0}'.format(
                    self.config['BOOT_SUCCESS_MESSAGE']))
                self.log.info(self.execute.message)

                # this is read by HDQ to decide whether DS container
                # boot was successful or not
                print self.config['BOOT_SUCCESS_MESSAGE']
                boot_file = open('/home/shippable/bootinfo.txt', 'a')
                boot_file.write('success')
                boot_file.close()
                sys.stdout.flush()

            self.execute.run()
        except Exception as exc:
            self.log.error(str(exc))
            trace = traceback.format_exc()
            self.log.debug(trace)
        return response
예제 #11
0
def main3():
    logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
    
    path = '/home/gujt/work/data/Aquant2-ctree/0/'
    exe = Execute()
    exe.build_model()
    #exe.load_model()
    #exit()  
    count = 0
    for dir in os.walk(path):
        for file in dir[2]:
            print 'read.',file
            f = open(path+file)
            line1 = f.readline()
            start = now()
            while line1:
                if count > 10:
                    exit()
                count += 1
                line2 = f.readline()
                lines = [line1, line2]
                try:
                    exe.train_sentence(lines)
                except:
                    '[BUG]',line2
                finally:
                    line1 = f.readline()
                    print '[',count,']', (now()-start),'s'
                    start = now()
                            
            f.close()
    
    print 'train ok.'
    exe.save_weights('../data/weights.bin') 
예제 #12
0
 def ButtonReleased( self, w, ev, ev2 ):
     if ev.button == 1:
         if not hasattr( self, "press_x" ) or \
                 not w.drag_check_threshold( int( self.press_x ),
                                                                          int( self.press_y ),
                                                                          int( ev.x ),
                                                                          int( ev.y ) ):
             if self.Win.pinmenu == False:
                 self.Win.wTree.get_widget( "window1" ).hide()
             if "applications" in self.Win.plugins:
                 self.Win.plugins["applications"].wTree.get_widget( "entry1" ).grab_focus()
             Execute( w, self.Exec )
예제 #13
0
def plan_run(request):
    if request.method == 'POST':
        plan_id = request.POST['plan_id']
        plan = Plan.objects.get(plan_id=plan_id)
        env_id = plan.environment.env_id
        case_id_list = eval(plan.content)
        case_num = len(case_id_list)
        content = []
        pass_num = 0
        fail_num = 0
        error_num = 0
        for case_id in case_id_list:
            execute = Execute(case_id, env_id)
            case_result = execute.run_case()
            content.append(case_result)
            if case_result["result"] == "pass":
                pass_num += 1
            if case_result["result"] == "fail":
                fail_num += 1
            if case_result["result"] == "error":
                error_num += 1
        report_name = plan.plan_name + "-" + time.strftime("%Y%m%d%H%M%S")
        if Report.objects.filter(plan=plan):
            Report.objects.filter(plan=plan).update(report_name=report_name,
                                                    content=content,
                                                    case_num=case_num,
                                                    pass_num=pass_num,
                                                    fail_num=fail_num,
                                                    error_num=error_num)
        else:
            report = Report(plan=plan,
                            report_name=report_name,
                            content=content,
                            case_num=case_num,
                            pass_num=pass_num,
                            fail_num=fail_num,
                            error_num=error_num)
            report.save()
        return HttpResponse(plan.plan_name + " 执行成功!")
예제 #14
0
파일: lawlbin.py 프로젝트: ittech25/LOLBITS
def main():
	global _username,_domain,_classes, prevId

	init()

	print(Fore.WHITE + Style.BRIGHT + printBanner() , end='')

	with open(baseWritePath + prevId, 'r') as f:
		first = json.load(f)

	nextId = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
	first['NextId'] =  nextId

	with open(baseWritePath + prevId, 'w') as f:
		json.dump(first, f)

	prevId = nextId

	content = waitAndReadFile(baseReadPath + prevId)

	userAndDomain = content['Output']
	userAndDomain = userAndDomain.split("\\")
	_domain = userAndDomain[0]
	_username = userAndDomain[1]
	


	_classes.append(Download())
	_classes.append(Execute())
	_classes.append(Move())
	_classes.append(Base64encode())
	_classes.append(Base64decode())
	_classes.append(Compile())
	_classes.append(Inject())
	_classes.append(Downexec())
	_classes.append(Powershell())
	_classes.append(Send())
	_classes.append(Impersonate())
	_classes.append(Exfiltrate())
	_classes.append(Runas())
	_classes.append(Shell())


	mainConsole()

	deinit()
예제 #15
0
파일: main.py 프로젝트: jshafer817/uvscada
def get_temperature_by_smartctl(device):
    '''
	[root@gespenst ~]# smartctl --all /dev/sdb
	...
	SMART Attributes Data Structure revision number: 16
	Vendor Specific SMART Attributes with Thresholds:
	ID# ATTRIBUTE_NAME		  FLAG	 VALUE WORST THRESH TYPE	  UPDATED  WHEN_FAILED RAW_VALUE
	  1 Raw_Read_Error_Rate	 0x002f   200   200   051	Pre-fail  Always	   -	   0
	  3 Spin_Up_Time			0x0027   188   180   021	Pre-fail  Always	   -	   1566
	  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   129
	  5 Reallocated_Sector_Ct   0x0033   200   200   140	Pre-fail  Always	   -	   0
	  7 Seek_Error_Rate		 0x002e   100   253   000	Old_age   Always	   -	   0
	  9 Power_On_Hours		  0x0032   099   099   000	Old_age   Always	   -	   863
	 10 Spin_Retry_Count		0x0032   100   100   051	Old_age   Always	   -	   0
	 11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
	 12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   124
	192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   103
	193 Load_Cycle_Count		0x0032   180   180   000	Old_age   Always	   -	   62042
	194 Temperature_Celsius	 0x0022   118   097   000	Old_age   Always	   -	   29
	196 Reallocated_Event_Count 0x0032   200   200   000	Old_age   Always	   -	   0
	197 Current_Pending_Sector  0x0032   200   200   000	Old_age   Always	   -	   0
	198 Offline_Uncorrectable   0x0030   100   253   000	Old_age   Offline	  -	   0
	199 UDMA_CRC_Error_Count	0x0032   200   200   000	Old_age   Always	   -	   0
	200 Multi_Zone_Error_Rate   0x0008   100   253   051	Old_age   Offline	  -	   0
	..
	'''
    command = "smartctl"
    args = list()

    args.append('-a')
    args.append(device)

    # go go go
    (rc, output) = Execute.with_output(command, args)
    '''
	[root@gespenst uvtemp]# smartctl /dev/sdf
	smartctl 5.40 2010-10-16 r3189 [i386-redhat-linux-gnu] (local build)
	Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

	Smartctl open device: /dev/sdf failed: No such device
	[root@gespenst uvtemp]# echo $?
	2
	'''
    """
	Too many obsecure conditions
	Try to parse and ignore if the parse fails

	[mcmaster@gespenst uvtemp]$ smartctl /dev/sda
	smartctl 5.40 2010-10-16 r3189 [i386-redhat-linux-gnu] (local build)
	Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

	Smartctl open device: /dev/sda failed: Permission denied

	rc_adj = rc / 256
	if rc_adj == 4:
		'''
		...
		smartctl 5.40 2010-10-16 r3189 [i386-redhat-linux-gnu] (local build)
		Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

		=== START OF INFORMATION SECTION ===
		Model Family:     Indilinx Barefoot based SSDs
		Device Model:     OCZ-AGILITY
		...
		Warning: device does not support Error Logging
		Warning! SMART ATA Error Log Structure error: invalid SMART checksum.
		SMART Error Log Version: 1
		No Errors Logged

		Warning! SMART Self-Test Log Structure error: invalid SMART checksum.
		SMART Self-test log structure revision number 1
		No self-tests have been logged.  [To run self-tests, use: smartctl -t]


		Device does not support Selective Self Tests/Logging
		
		
		Still had table info though, but not temp
		'''
		return None
	elif not rc == 0:
		print output
		# This happens for a number of reasons, hard to guage
		print 'Bad rc: %d (%d)' % (rc_adj, rc)
		return None
	"""
    if output is None:
        return None

    print_debug()
    print_debug()
    print_debug(output)
    print_debug()
    print_debug()
    # 194 Temperature_Celsius     0x0022   117   097   000    Old_age   Always       -       30
    re_res = re.search(".*Temperature_Celsius.*", output)
    if re_res is None:
        return None
    line = re_res.group()
    if line is None:
        return None
    print_debug('line: %s' % repr(line))

    worst_temp = float(line.split()[4])
    print_debug('worst: %s' % worst_temp)
    cur_temp = float(line.split()[9])
    print_debug('cur: %s' % cur_temp)

    return (cur_temp, worst_temp)
예제 #16
0
파일: kernel.py 프로젝트: veghen/Y86
    lst.write('E', cur.regE)
    lst.write('M', cur.regM)
    lst.write('W', cur, regW)


mem = Memory()
InsCode = {}
Init(InsCode, mem)
reg = Register()
pipereg = PipeRegister()
tmp_pipereg = PipeRegister()
CC = ConditionCode()
Stat = Status()

PC = 0
while Stat.stat == 'AOK':
    print 'Current Time:', PC
    tmp_pipereg = PipeRegister()
    Fetch(tmp_pipereg, InsCode[hex(PC)], PC)
    Decode(pipereg, tmp_pipereg, reg)
    Execute(pipereg, tmp_pipereg)
    Memory(pipereg, tmp_pipereg)
    WriteBack(pipereg, tmp_pipereg)
    PC = pipereg.regF['predPC']
    Update(cur=tmp_pipereg, lst=pipireg)
    print 'RegF:', reg.regF
    print 'RegD:', reg.regD
    print 'RegE:', reg.regE
    print 'RegM:', reg.regM
    print 'RegW:', reg.regW
예제 #17
0
파일: mark.py 프로젝트: aluckyi/MarkGT
class Mark(MainUI):

    def __init__(self):
        super().__init__()

        self.exe = Execute()
        self.img_lbl.initXYBoxObjs(self.x_box, self.y_box)
        self.img_lbl.initReferLineNumObj(self.ref_num_lbl)
        self.img_lbl.initHorizonModifyObj(self.horizon_modify_btn)
        self.img_lbl.initSLObsNumObjs(self.small_obs_num_lbl, self.large_obs_num_lbl)

        self.start_flag = False
        self.mode = 'Horizon'
        self.horizon_method = 'Manual'
        self.refer_lines_flag = False
        self.obs_cls = 'Small Obstacle'

    def srcBtnRespond(self):
        home_dir = osp.expanduser('~')
        dir_name = QFileDialog.getExistingDirectory(self, 'Select Directory', home_dir)
        self.src_show_box.setText(dir_name)
        self.exe.setSrcDir(dir_name)

    def dstBtnRespond(self):
        home_dir = osp.expanduser('~')
        dir_name = QFileDialog.getExistingDirectory(self, 'Select Directory', home_dir)
        self.dst_show_box.setText(dir_name)
        self.exe.setDstDir(dir_name)

    def modeRespond(self):
        source = self.sender()
        # print(source.text())
        if source.text() == 'Horizon':
            self.mode = 'Horizon'
            self.img_lbl.setMode(self.mode)
            self.h_square.setStyleSheet("QWidget { background-color: rgb(0, 255, 0); }")
            self.o_square.setStyleSheet("QWidget { background-color: rgb(180, 180, 180); }")
        else:
            self.mode = 'Obstacle'
            self.img_lbl.setMode(self.mode)
            self.h_square.setStyleSheet("QWidget { background-color: rgb(180, 180, 180); }")
            self.o_square.setStyleSheet("QWidget { background-color: rgb(0, 255, 0); }")

            self.img_lbl.setHorizonModifyFlag(False)
            self.horizon_modify_btn.setChecked(False)

    def horizonMethodRespond(self):
        source = self.sender()
        if source.text() == 'Manual':
            self.horizon_method = 'Manual'
        else:
            self.horizon_method = 'Auto'

    def referLinesBtnRespond(self, value):
        self.img_lbl.setReferLines(value)

    def horizonModifyBtnRespond(self, value):
        if not self.start_flag:
            QMessageBox.warning(self, 'warning', 'Please press [Start] or [Restore]!!!')
            self.horizon_modify_btn.setChecked(False)
            return

        if value:
            if self.mode != 'Horizon':
                QMessageBox.warning(self, 'warning', 'The [Mode] must be "Horizon" !!!')
                self.horizon_modify_btn.setChecked(False)
                return

            ret = self.img_lbl.setHorizonModifyFlag(value)
            if ret < 0:
                QMessageBox.warning(self, 'warning', 'The horizon has not been marked!!!')
                self.horizon_modify_btn.setChecked(False)
                return
        else:
            self.img_lbl.setHorizonModifyFlag(value)

    def obsClsBtnRespond(self):
        source = self.sender()
        if source.text() == 'Small Obstacle':
            self.obs_cls = 'Small Obstacle'
            self.img_lbl.setObsCls(self.obs_cls)
            obs_cls_col = QColor(*cfg.SMALL_OBS_COLOR)
            self.obs_cls_square.setStyleSheet("QWidget { background-color: %s }" % obs_cls_col.name())
        else:
            self.obs_cls = 'Large Obstacle'
            self.img_lbl.setObsCls(self.obs_cls)
            obs_cls_col = QColor(*cfg.LARGE_OBS_COLOR)
            self.obs_cls_square.setStyleSheet("QWidget { background-color: %s }" % obs_cls_col.name())
        # print(self.obs_cls)

    def startBtnRespond(self):
        if self.start_flag:
            reply = QMessageBox.question(self, 'warning', "Are you sure to restart?",
                                         QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
            if reply == QMessageBox.No:
                return
            else:
                self.exe.reset()

        ret = self.exe.start()
        if ret == -1:
            QMessageBox.warning(self, 'warning', 'Please Select SRC Path!!!')
            return
        if ret == -2:
            QMessageBox.warning(self, 'warning', 'Please Select DST Path!!!')
            return
        if ret == -3:
            QMessageBox.warning(self, 'warning', 'No jpg or png images in SRC Path!!!')
            return

        self.display(isFinished=False)
        self.img_lbl.setEnableImageFlag(True)
        self.img_lbl.reset()

        self.start_flag = True

    def restoreBtnRespond(self):
        reply = QMessageBox.question(self, 'warning', "Are you sure to restore?",
                                     QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
        if reply == QMessageBox.No:
            return

        ret = self.exe.restore()
        if ret < 0:
            QMessageBox.warning(self, 'warning', 'Some problems exist, cannot restore!!!')
            return

        self.display(isFinished=False)
        self.img_lbl.setEnableImageFlag(True)
        self.img_lbl.reset()

        self.start_flag = True

    def undoBtnRespond(self):
        if not self.start_flag:
            QMessageBox.warning(self, 'warning', 'Please press [Start] or [Restore]!!!')
            return
        ret = self.img_lbl.undo()
        if ret == -1:
            QMessageBox.warning(self, 'warning', 'All marks are removed!!!')

    def nextBtnRespond(self):
        if not self.start_flag:
            QMessageBox.warning(self, 'warning', 'Please press [Start] or [Restore]!!!')
            return

        horizon_data, obs_data = self.img_lbl.getData()
        ret = self.exe.saveData(horizon_data, obs_data)
        if ret == -1:
            QMessageBox.warning(self, 'warning', 'Marking Horizon has not completed!!!')
            return
        if ret == -2:
            self.display(isFinished=True)
            reply = QMessageBox.question(self, 'warning',
                                         'All marking has completed!!!, Are you sure to finish?',
                                         QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
            if reply == QMessageBox.No:
                self.img_lbl.reset()
                return
            self.reset()
            return

        self.img_lbl.reset()
        self.display(isFinished=False)

    def reset(self):
        self.start_flag = False

        self.src_show_box.clear()
        self.dst_show_box.clear()

        self.img_lbl.clear()
        self.img_lbl.setEnableImageFlag(False)
        self.img_lbl.reset()

        self.cur_img_box.clear()
        self.no_box.clear()
        self.total_box.clear()
        self.pbar.reset()
        self.x_box.clear()
        self.y_box.clear()

        self.ref_num_lbl.clear()
        self.small_obs_num_lbl.clear()
        self.large_obs_num_lbl.clear()

        self.exe.setSrcDir('')
        self.exe.setDstDir('')
        self.exe.reset()
        self.exe.saveConfig()

    def display(self, isFinished):
        cur_image_name = self.exe.getCurrentImageName()
        cur_image_no = self.exe.getCurrentImageNo()
        total_image_num = self.exe.getTotalImageNum()

        src_dir = self.exe.getSrcDir()
        dst_dir = self.exe.getDstDir()
        self.src_show_box.setText(src_dir)
        self.dst_show_box.setText(dst_dir)
        self.cur_img_box.setText(cur_image_name)
        self.no_box.setText(str(cur_image_no + 1))
        self.total_box.setText(str(total_image_num))

        if isFinished:
            pb_val = int((float(cur_image_no + 1) / total_image_num) * 100)
        else:
            pb_val = int((float(cur_image_no) / total_image_num) * 100)
        self.pbar.setValue(pb_val)

        self.ref_num_lbl.setText(str(0))
        self.small_obs_num_lbl.setText(str(0))
        self.large_obs_num_lbl.setText(str(0))

        self.img_lbl.loadFromDisk(osp.join(cfg.SRC_DIR, cur_image_name))
예제 #18
0
파일: RNA2DNAlign.py 프로젝트: qingnanl/NGS
else:
    scriptdir = dirname(realpath(sys.argv[0]))
    scriptdir1 = realpath(join(scriptdir, '..', '..', 'common', 'src'))
    sys.path.append(scriptdir1)
    scriptdir2 = realpath(join(scriptdir, '..', '..', 'ReadCounts', 'src'))
    scriptdirs = [scriptdir,scriptdir1,scriptdir2]

try:
    scriptextn = "." + os.path.split(sys.argv[0])[1].rsplit('.', 1)[1]
except:
    scriptextn = ""

from pileups import SerialPileups, ThreadedPileups, MultiprocPileups
from chromreg import ChromLabelRegistry
from execute import Execute
execprog = Execute(*scriptdirs,extn=scriptextn)

from optparse_gui import OptionParser, OptionGroup, GUI, UserCancelledError, ProgressText
from util import *

from operator import itemgetter

from version import VERSION
VERSION = '%s' % (VERSION,)


def excepthook(etype, value, tb):
    traceback.print_exception(etype, value, tb)
    print("Type <Enter> to Exit...", end=' ', file=sys.stderr)
    sys.stderr.flush()
    input()
예제 #19
0
def get_temperature_by_smartctl(device):
	'''
	[root@gespenst ~]# smartctl --all /dev/sdb
	...
	SMART Attributes Data Structure revision number: 16
	Vendor Specific SMART Attributes with Thresholds:
	ID# ATTRIBUTE_NAME		  FLAG	 VALUE WORST THRESH TYPE	  UPDATED  WHEN_FAILED RAW_VALUE
	  1 Raw_Read_Error_Rate	 0x002f   200   200   051	Pre-fail  Always	   -	   0
	  3 Spin_Up_Time			0x0027   188   180   021	Pre-fail  Always	   -	   1566
	  4 Start_Stop_Count		0x0032   100   100   000	Old_age   Always	   -	   129
	  5 Reallocated_Sector_Ct   0x0033   200   200   140	Pre-fail  Always	   -	   0
	  7 Seek_Error_Rate		 0x002e   100   253   000	Old_age   Always	   -	   0
	  9 Power_On_Hours		  0x0032   099   099   000	Old_age   Always	   -	   863
	 10 Spin_Retry_Count		0x0032   100   100   051	Old_age   Always	   -	   0
	 11 Calibration_Retry_Count 0x0032   100   100   000	Old_age   Always	   -	   0
	 12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   124
	192 Power-Off_Retract_Count 0x0032   200   200   000	Old_age   Always	   -	   103
	193 Load_Cycle_Count		0x0032   180   180   000	Old_age   Always	   -	   62042
	194 Temperature_Celsius	 0x0022   118   097   000	Old_age   Always	   -	   29
	196 Reallocated_Event_Count 0x0032   200   200   000	Old_age   Always	   -	   0
	197 Current_Pending_Sector  0x0032   200   200   000	Old_age   Always	   -	   0
	198 Offline_Uncorrectable   0x0030   100   253   000	Old_age   Offline	  -	   0
	199 UDMA_CRC_Error_Count	0x0032   200   200   000	Old_age   Always	   -	   0
	200 Multi_Zone_Error_Rate   0x0008   100   253   051	Old_age   Offline	  -	   0
	..
	'''
	command = "smartctl"
	args = list()
	
	args.append('-a')
	args.append(device)
	
	# go go go
	(rc, output) = Execute.with_output(command, args)
	'''
	[root@gespenst uvtemp]# smartctl /dev/sdf
	smartctl 5.40 2010-10-16 r3189 [i386-redhat-linux-gnu] (local build)
	Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

	Smartctl open device: /dev/sdf failed: No such device
	[root@gespenst uvtemp]# echo $?
	2
	'''
	"""
	Too many obsecure conditions
	Try to parse and ignore if the parse fails

	[mcmaster@gespenst uvtemp]$ smartctl /dev/sda
	smartctl 5.40 2010-10-16 r3189 [i386-redhat-linux-gnu] (local build)
	Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

	Smartctl open device: /dev/sda failed: Permission denied

	rc_adj = rc / 256
	if rc_adj == 4:
		'''
		...
		smartctl 5.40 2010-10-16 r3189 [i386-redhat-linux-gnu] (local build)
		Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

		=== START OF INFORMATION SECTION ===
		Model Family:     Indilinx Barefoot based SSDs
		Device Model:     OCZ-AGILITY
		...
		Warning: device does not support Error Logging
		Warning! SMART ATA Error Log Structure error: invalid SMART checksum.
		SMART Error Log Version: 1
		No Errors Logged

		Warning! SMART Self-Test Log Structure error: invalid SMART checksum.
		SMART Self-test log structure revision number 1
		No self-tests have been logged.  [To run self-tests, use: smartctl -t]


		Device does not support Selective Self Tests/Logging
		
		
		Still had table info though, but not temp
		'''
		return None
	elif not rc == 0:
		print output
		# This happens for a number of reasons, hard to guage
		print 'Bad rc: %d (%d)' % (rc_adj, rc)
		return None
	"""
	if output is None:
		return None
	
	print_debug()
	print_debug()
	print_debug(output)
	print_debug()
	print_debug()
	# 194 Temperature_Celsius     0x0022   117   097   000    Old_age   Always       -       30
	re_res = re.search(".*Temperature_Celsius.*", output)
	if re_res is None:
		return None
	line = re_res.group()
	if line is None:
		return None
	print_debug('line: %s' % repr(line))

	worst_temp = float(line.split()[4])
	print_debug('worst: %s' % worst_temp)
	cur_temp = float(line.split()[9])
	print_debug('cur: %s' % cur_temp)

	return (cur_temp, worst_temp)
예제 #20
0
파일: main.py 프로젝트: Bharath92/cexec
import os
from execute import Execute

if __name__ == '__main__':
    print('Booting up CEXEC')
    executor = Execute()
    print('Running CEXEC script')
    exit_code=executor.run()
    print('CEXEC has completed')
    os._exit(exit_code)
예제 #21
0
import math
from collections import defaultdict, Counter
from os.path import join, dirname, realpath, split
try:
    scriptdir = dirname(realpath(__file__))
except NameError:
    scriptdir = dirname(realpath(sys.argv[0]))
scriptdir1 = realpath(join(scriptdir, '..', '..', 'common', 'src'))
sys.path.append(scriptdir1)
try:
    scriptextn = "." + os.path.split(sys.argv[0])[1].rsplit('.', 1)[1]
except:
    scriptextn = ""

from execute import Execute
execprog = Execute(scriptdir,scriptdir1,extn=scriptextn)

from optparse_gui import OptionParser, OptionGroup, GUI, UserCancelledError, ProgressText
from util import *

from operator import itemgetter

from version import VERSION
VERSION = '1.0.6 (%s)' % (VERSION,)


def excepthook(etype, value, tb):
    traceback.print_exception(etype, value, tb)
    print >>sys.stderr, "Type <Enter> to Exit...",
    sys.stderr.flush()
    raw_input()
예제 #22
0
파일: downexec.py 프로젝트: y11en/LOLBITS
    def downexec(self, cmdSpl):

        d = Download()
        e = Execute()
        d.executeCommand(cmdSpl)
        e.executeCommand(cmdSpl[1:])
예제 #23
0
import os
from execute import Execute

if __name__ == '__main__':
    print('Booting up CEXEC')
    executor = Execute()
    print('Running CEXEC script')
    exit_code = executor.run()
    print('CEXEC has completed')
    os._exit(exit_code)
예제 #24
0
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 19 16:39:05 2016

@author: tanfan.zjh
"""

from structure import DependencyTree as tree
import DepNN as nn
from execute import Execute as exe

lines = ('[(S (NP (DT Those) (NN space)) (VP (VBZ walks) (SBAR (S (VP (VBP are) (S (VP (TO to) (VP (VB be) (VP (VBN used) (PP (IN for) (S (VP (VBG preparing) (NP (NP (DT the) (NNP ISS)) (PP (IN for) (NP (NP (DT the) (VBN planned) (NN docking)) (NP (JJ next) (NN year)) (PP (IN of) (NP (DT the) (JJ new) (NNP European) (NNP ATV) (NN space) (NN cargo) (NN vessel))))))))))))))))) (. .))]','[det(space-2, Those-1), nsubj(walks-3, space-2), root(ROOT-0, walks-3), ccomp(walks-3, are-4), aux(used-7, to-5), auxpass(used-7, be-6), xcomp(are-4, used-7), prepc_for(used-7,preparing-9), det(ISS-11, the-10), dobj(preparing-9, ISS-11), det(docking-15, the-13), amod(docking-15, planned-14), prep_for(ISS-11, docking-15), amod(year-17, next-16), dep(docking-15, year-17), det(vessel-25, the-19), amod(vessel-25, new-20), nn(vessel-25, European-21), nn(vessel-25, ATV-22), nn(vessel-25, space-23), nn(vessel-25, cargo-24), prep_of(docking-15, vessel-25)]')
exe.train_sentence(lines[1])
    
예제 #25
0
파일: SNPlice.py 프로젝트: qingnanl/NGS
import time
from collections import defaultdict, Counter
from os.path import join, dirname, realpath, split
try:
    scriptdir = dirname(realpath(__file__))
except NameError:
    scriptdir = dirname(realpath(sys.argv[0]))
scriptdir1 = realpath(join(scriptdir, '..', '..', 'common', 'src'))
sys.path.append(scriptdir1)
try:
    scriptextn = "." + os.path.split(sys.argv[0])[1].rsplit('.', 1)[1]
except:
    scriptextn = ""

from execute import Execute
execprog = Execute(scriptdir, scriptdir1, extn=scriptextn)

from optparse_gui import OptionParser, OptionGroup, GUI, UserCancelledError, ProgressText
from util import *

from version import VERSION
VERSION = '%s' % (VERSION, )


def excepthook(etype, value, tb):
    traceback.print_exception(etype, value, tb)
    print("Type <Enter> to Exit...", end=' ', file=sys.stderr)
    sys.stderr.flush()
    input()

예제 #26
0
 def __init__(self):
     self.utils = Utils()
     self.execute = Execute()
     self.filereader = FileReader()
예제 #27
0
class Parser:
    def __init__(self):
        self.utils = Utils()
        self.execute = Execute()
        self.filereader = FileReader()

    def parse_query(self, query, dictionary):
        if query:
            query = self.utils.spaces_rem(query)
        keywords = ["from", "select", "distinct", "where"]
        parsedquery = {}
        d = tuple()
        for k in keywords:
            if k in query and k == "from":
                parsedquery[k] = query.split(k)
            elif k == "select" and k in parsedquery["from"][0].strip():
                parsedquery['select'] = self.utils.spaces_rem(parsedquery["from"][0].strip().split('select')[1])
            elif k == "distinct" and k in parsedquery['select']:
                parsedquery[k] = self.utils.spaces_rem(parsedquery['select'].strip().split('distinct')[1])
                distinct = True
            elif k == "distinct" and k not in parsedquery['select']:
                parsedquery[k] = self.utils.spaces_rem(parsedquery['select'])
                distinct = False
            elif k == "where":
                parsedquery['where'] = self.utils.spaces_rem(parsedquery['from'][1]).split('where')
                tableNames = [self.utils.spaces_rem(x) for x in
                              self.utils.spaces_rem(parsedquery['where'][0]).split(',')]
                self.filereader.check_tables(tableNames, dictionary)
            else:
                sys.exit("No" + k + "Clause")
        parsedquery['distinct'] = self.utils.spaces_rem(parsedquery["distinct"])
        parsedquery['distinct'] = [self.utils.spaces_rem(x) for x in parsedquery["distinct"].split(',')]

        if distinct:
            for a in parsedquery['distinct']:
                if '(' in a or ')' in a:
                    d_att = a.split('(')[1][:-1]
                    if d_att:
                        parsedquery['distinct'][parsedquery['distinct'].index(a)] = d_att
                        break
            aggregation = ""

            x = self.filereader.add_tableName([d_att], tableNames, dictionary)
            d = (x[0], True)

        aggr_func = ""
        temp = []
        for a in parsedquery['distinct']:
            if '(' in a or ')' in a:
                print(a)
                aggr_func = a
            else:
                temp.append(a)
        parsedquery['distinct'] = temp

        if aggr_func:
            if '.' not in aggr_func:
                print(aggr_func)
                parsedquery['distinct'] = [self.utils.spaces_rem(aggr_func).split('(')[1][:-1]]
                parsedquery['distinct'] = self.filereader.add_tableName(parsedquery['distinct'], tableNames, dictionary)
                aggr_func = self.utils.spaces_rem(aggr_func).split('(')[0] + '(' + parsedquery['distinct'][0] + ')'

        parsedquery['distinct'] = self.filereader.add_tableName(parsedquery['distinct'], tableNames, dictionary)
        parsedquery['distinct'] = self.utils.check_attributes(parsedquery['distinct'], tableNames, dictionary)

        if len(parsedquery['where']) > 1:
            conditions = self.utils.spaces_rem(parsedquery['where'][1])
        else:
            conditions = ""
        self.execute.run(dictionary, tableNames, parsedquery['distinct'], conditions, d, aggr_func)
예제 #28
0
class Gui_Main(QtGui.QMainWindow):
    """
    The main window of the app
    """
    def __init__(self, main):
        """
        Parent constructor call,
        call setup for gui, 
        create thread object for 
        the script and connect signals
        to slots
        """
        super(Gui_Main, self).__init__()
        self.setupUi(main)
        self.execute = Execute()
        self.connect(self.execute, SIGNAL("setOutput(QString)"),
                     self.setOutput)
        self.connect(self.execute, SIGNAL("finished(bool)"), self.finished)
        self.step = 0

    def setupUi(self, MainWindow):
        """
        Create gui widget etc 
        and connect signals to slots
        """
        MainWindow.setObjectName(_fromUtf8("Despeckle"))
        MainWindow.resize(716, 873)

        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))

        self.widget = QtGui.QWidget(self.centralwidget)
        self.widget.setGeometry(QtCore.QRect(10, 750, 291, 41))
        self.widget.setObjectName(_fromUtf8("widget"))

        self.progressBar = QtGui.QProgressBar(self.widget)
        self.progressBar.setGeometry(QtCore.QRect(107, 10, 221, 23))
        self.progressBar.setProperty("value", 0)
        self.progressBar.setObjectName(_fromUtf8("progressBar"))

        self.widget_2 = QtGui.QWidget(self.centralwidget)
        self.widget_2.setGeometry(QtCore.QRect(410, 750, 291, 41))
        self.widget_2.setObjectName(_fromUtf8("widget_2"))

        self.widget_3 = QtGui.QWidget(self.centralwidget)
        self.widget_3.setGeometry(QtCore.QRect(10, 40, 691, 331))
        self.widget_3.setObjectName(_fromUtf8("widget_3"))

        MainWindow.setCentralWidget(self.centralwidget)

        self.textEdit = QtGui.QTextEdit(self.widget_3)
        self.textEdit.setGeometry(QtCore.QRect(110, 50, 501, 31))
        self.textEdit.setObjectName(_fromUtf8("textEdit"))

        self.textEdit_2 = QtGui.QTextEdit(self.widget_3)
        self.textEdit_2.setGeometry(QtCore.QRect(110, 100, 501, 31))
        self.textEdit_2.setObjectName(_fromUtf8("textEdit_2"))

        self.textEdit_3 = QtGui.QTextEdit(self.widget_3)
        self.textEdit_3.setGeometry(QtCore.QRect(110, 150, 501, 31))
        self.textEdit_3.setObjectName(_fromUtf8("textEdit_3"))

        self.textEdit_4 = QtGui.QTextEdit(self.widget_3)
        self.textEdit_4.setGeometry(QtCore.QRect(110, 200, 251, 31))
        self.textEdit_4.setObjectName(_fromUtf8("textEdit_4"))

        self.textEdit_5 = QtGui.QTextEdit(self.widget_3)
        self.textEdit_5.setGeometry(QtCore.QRect(110, 250, 251, 31))
        self.textEdit_5.setObjectName(_fromUtf8("textEdit_5"))

        self.plainTextEdit = QtGui.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit.setGeometry(QtCore.QRect(119, 420, 501, 321))
        self.plainTextEdit.setObjectName(_fromUtf8("plainTextEdit"))
        self.plainTextEdit.setReadOnly(True)

        self.label = QtGui.QLabel(self.widget_2)
        self.label.setGeometry(QtCore.QRect(20, 10, 201, 21))
        self.label.setObjectName(_fromUtf8("label"))

        self.label_2 = QtGui.QLabel(self.widget_3)
        self.label_2.setGeometry(QtCore.QRect(30, 50, 41, 31))
        self.label_2.setObjectName(_fromUtf8("label_2"))

        self.label_3 = QtGui.QLabel(self.widget_3)
        self.label_3.setGeometry(QtCore.QRect(30, 100, 21, 31))
        self.label_3.setObjectName(_fromUtf8("label_3"))

        self.label_4 = QtGui.QLabel(self.widget_3)
        self.label_4.setGeometry(QtCore.QRect(30, 150, 51, 31))
        self.label_4.setObjectName(_fromUtf8("label_4"))

        self.label_5 = QtGui.QLabel(self.widget_3)
        self.label_5.setGeometry(QtCore.QRect(30, 200, 81, 31))
        self.label_5.setObjectName(_fromUtf8("label_5"))

        self.label_6 = QtGui.QLabel(self.widget_3)
        self.label_6.setGeometry(QtCore.QRect(30, 250, 51, 31))
        self.label_6.setObjectName(_fromUtf8("label_6"))

        self.label_7 = QtGui.QLabel(self.centralwidget)
        self.label_7.setGeometry(QtCore.QRect(310, 380, 101, 31))
        self.label_7.setObjectName(_fromUtf8("label_7"))

        self.label_8 = QtGui.QLabel(self.widget_3)
        self.label_8.setGeometry(QtCore.QRect(450, 200, 151, 20))
        self.label_8.setObjectName(_fromUtf8("label_8"))

        self.label_9 = QtGui.QLabel(self.widget_3)
        self.label_9.setGeometry(QtCore.QRect(450, 250, 151, 20))
        self.label_9.setObjectName(_fromUtf8("label_9"))

        icon = QtGui.QIcon()
        icon.addPixmap(
            QtGui.QPixmap(
                _fromUtf8("/opt/Despeckle_pyqt/icons/view_tree.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)

        self.pushButton = QtGui.QPushButton(self.widget_3)
        self.pushButton.setGeometry(QtCore.QRect(630, 50, 41, 31))
        self.pushButton.setText(_fromUtf8(""))
        self.pushButton.setIcon(icon)
        self.pushButton.setIconSize(QtCore.QSize(42, 42))
        self.pushButton.setObjectName(_fromUtf8("pushButton"))
        self.pushButton.clicked.connect(self.inputButtonClicked)

        self.pushButton_2 = QtGui.QPushButton(self.widget_3)
        self.pushButton_2.setGeometry(QtCore.QRect(630, 100, 41, 31))
        self.pushButton_2.setText(_fromUtf8(""))
        self.pushButton_2.setIcon(icon)
        self.pushButton_2.setIconSize(QtCore.QSize(42, 42))
        self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
        self.pushButton_2.clicked.connect(self.outputButtonClicked)

        self.pushButton_3 = QtGui.QPushButton(self.widget_3)
        self.pushButton_3.setGeometry(QtCore.QRect(630, 150, 41, 31))
        self.pushButton_3.setText(_fromUtf8(""))
        self.pushButton_3.setIcon(icon)
        self.pushButton_3.setIconSize(QtCore.QSize(42, 42))
        self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
        self.pushButton_3.clicked.connect(self.inputKernelButtonClicked)

        self.pushButton_4 = QtGui.QPushButton(self.widget_3)
        self.pushButton_4.setGeometry(QtCore.QRect(630, 200, 41, 31))
        self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
        self.pushButton_4.setIcon(icon)
        self.pushButton_4.setIconSize(QtCore.QSize(42, 42))
        self.pushButton_4.clicked.connect(self.statsButton)

        self.pushButton_5 = QtGui.QPushButton(self.widget_3)
        self.pushButton_5.setGeometry(QtCore.QRect(630, 250, 41, 31))
        self.pushButton_5.setObjectName(_fromUtf8("pushButton_5"))
        self.pushButton_5.setIcon(icon)
        self.pushButton_5.setIconSize(QtCore.QSize(42, 42))
        self.pushButton_5.clicked.connect(self.statsButton2)

        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 716, 20))
        self.menubar.setObjectName(_fromUtf8("menubar"))

        self.menu_File = QtGui.QMenu(self.menubar)
        self.menu_File.setObjectName(_fromUtf8("menu_File"))
        self.menu_Help = QtGui.QMenu(self.menubar)
        self.menu_Help.setObjectName(_fromUtf8("menu_Help"))
        self.menu_Help.triggered.connect(self.aboutClicked)

        MainWindow.setMenuBar(self.menubar)

        self.toolBar = QtGui.QToolBar(MainWindow)
        self.toolBar.setObjectName(_fromUtf8("toolBar"))
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)

        self.action_Run = QtGui.QAction(MainWindow)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(
            QtGui.QPixmap(_fromUtf8("/opt/Despeckle_pyqt/icons/guiRun.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.On)
        self.action_Run.setIcon(icon1)
        self.action_Run.setObjectName(_fromUtf8("action_Run"))
        self.action_Run.triggered.connect(self.action_Run_Clicked)

        self.actionStop = QtGui.QAction(MainWindow)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(
            QtGui.QPixmap(_fromUtf8("/opt/Despeckle_pyqt/icons/guiStop.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.On)
        self.actionStop.setIcon(icon2)
        self.actionStop.setObjectName(_fromUtf8("actionStop"))
        self.actionStop.triggered.connect(self.action_Stop_Clicked)

        self.action_Exit = QtGui.QAction(MainWindow)

        icon3 = QtGui.QIcon()
        icon3.addPixmap(
            QtGui.QPixmap(
                _fromUtf8("/opt/Despeckle_pyqt/icons/fileclose.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.On)

        self.action_Exit.setIcon(icon3)
        self.action_Exit.setObjectName(_fromUtf8("action_Exit"))
        self.action_Exit.triggered.connect(QtGui.qApp.quit)

        self.toolBar.addAction(self.action_Run)
        self.toolBar.addAction(self.actionStop)
        self.toolBar.addAction(self.action_Exit)
        self.toolBar.addSeparator()

        self.action_About_Despeckle = QtGui.QAction(MainWindow)
        self.action_About_Despeckle.setObjectName(
            _fromUtf8("action_About_Despeckle"))

        self.menu_File.addAction(self.action_Run)
        self.menu_File.addAction(self.actionStop)
        self.menu_File.addAction(self.action_Exit)
        self.menu_File.addSeparator()
        self.menu_Help.addAction(self.action_About_Despeckle)

        self.menubar.addAction(self.menu_File.menuAction())
        self.menubar.addAction(self.menu_Help.menuAction())

        self.retranslateUi(MainWindow)

        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):

        MainWindow.setWindowTitle(_translate("Despeckle", "Despeckle", None))

        self.label.setText(_translate("MainWindow", "ERROR", None))
        self.label_2.setText(_translate("MainWindow", "FROM", None))
        self.label_3.setText(_translate("MainWindow", "TO", None))
        self.label_4.setText(_translate("MainWindow", "KERNEL", None))
        self.label_5.setText(_translate("MainWindow", "ITERATIONS", None))
        self.label_6.setText(_translate("MainWindow", "L value", None))
        self.label_7.setText(_translate("MainWindow", "Console Output", None))
        self.label_8.setText(
            _translate("MainWindow", "Input image statistics", None))
        self.label_9.setText(
            _translate("MainWindow", "Output image statistics", None))

        self.menu_File.setTitle(_translate("MainWindow", "&File", None))
        self.menu_Help.setTitle(_translate("MainWindow", "&Help", None))

        self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None))

        self.action_Run.setText(_translate("MainWindow", "&Run", None))
        self.actionStop.setText(_translate("MainWindow", "Stop", None))
        self.action_Exit.setText(_translate("MainWindow", "&Exit", None))
        self.action_About_Despeckle.setText(
            _translate("MainWindow", "&About Despeckle", None))

    def inputButtonClicked(self):
        """
        When button pushed, select input .cub file
        and set the path to textedit field and prevent 
        user from changing path manualy
        """
        filename = QtGui.QFileDialog.getOpenFileName(None, 'Select file',
                                                     "*.cub", "*.cub")
        self.textEdit.setText(filename)
        self.textEdit.setEnabled(0)

    def outputButtonClicked(self):
        """
        When button pushed, select output .cub file
        and set the path to textedit field and prevent 
        user from changing path manualy
        """
        filename = QtGui.QFileDialog.getSaveFileName(None, "Select file",
                                                     ".cub", ".cub")

        self.textEdit_2.setText(filename)
        self.textEdit_2.setEnabled(0)

    def inputKernelButtonClicked(self):
        """
        When button pushed, select kernel.txt file
        and set the path to textedit field and prevent 
        user from changing path manualy
        """
        filename = QtGui.QFileDialog.getOpenFileName(None, 'Select file',
                                                     "*.txt", "*.txt")
        self.textEdit_3.setText(filename)
        self.textEdit_3.setEnabled(0)

    def action_Run_Clicked(self):
        """
        Main function of the program. 
        Gets the paths, sets default values
        when new values aren't given,sets
        the command to the thread object (execute)
        and starts the thread.
        Also sets the output of the bottom label
        and the progress bar
        """

        input_cub_path = self.textEdit.toPlainText()
        output_cub_path = self.textEdit_2.toPlainText()
        input_kernel_path = self.textEdit_3.toPlainText()
        l_value = self.textEdit_5.toPlainText()
        iterations = self.textEdit_4.toPlainText()

        if (not l_value):
            l_value = '-l 0.08'
        else:
            l_value = '-l ' + l_value

        if (not iterations):
            iterations = '-i 100'
            self.maxIterations = 100
        else:
            self.maxIterations = int(iterations)
            iterations = '-i ' + iterations

        # Set max number to progress bar --> number of total iterations, 100 by default
        self.progressBar.setMaximum(self.maxIterations)

        if (not input_cub_path or not output_cub_path
                or not input_kernel_path):
            print("Error")
        else:
            self.cmd = "sh /opt/Despeckle_pyqt/Despeckle/a_despeckle.sh " + input_cub_path + ' ' + input_kernel_path + ' ' + ' ' + output_cub_path + ' ' + l_value + ' ' + iterations

            self.execute.setCmd(self.cmd)

            self.execute.start()

            print("is finished", self.execute.isFinished())

    def finished(self, completed):
        if (self.execute.isRunning()):
            return
        if (completed):
            print("Thread finished")
            self.label.setText("Finished")
        else:
            print("stopped")
            self.label.setText("Cancelled")

    def setOutput(self, mystr):
        """
        Redirects stdout given from signal
        to plainTextEdit and send given 
        string to bar and label
        """
        self.plainTextEdit.appendPlainText(mystr)
        self.setOutputBar(mystr)
        self.setOutputLabel(mystr)

    def setOutputBar(self, mystr):
        """
        In bash script is echoed
        the word "Iteration" following
        a number showing us the current
        iteration, so when our line starts
        with the word "Iteration" we take 
        the string after that word (the number),
        we cast it to integer and we set
        the value of the progress bar 
        """
        if (mystr.startswith("Iteration")):
            currentIteration = int(mystr[9:])
            self.progressBar.setValue(currentIteration)

    def setOutputLabel(self, mystr):
        """
        In bash script is echoed
        the word "Iteration" following
        a number showing us the current
        iteration, so when our line starts
        with the word "Iteration" we take 
        the whole line (string) and we
        set the value of the label  
        """
        if (mystr.startswith("Iteration")):
            self.label.setText(mystr)

    def action_Stop_Clicked(self):
        """
        A not-an-elegant
        way to stop the thread 
        """
        self.execute.stop()

    def statsButton(self):
        """
        When button pushed, a stats
        frame pops up with the stats
        of the input image.
        """
        path = self.textEdit.toPlainText()
        if (not path):
            pass
        else:
            self.stats1 = StatsPopup(path)
            self.stats1.start()

    def statsButton2(self):
        """
        When button pushed, a stats
        frame pops up with the stats
        of the output image.
        """
        path = self.textEdit_2.toPlainText()
        if (not path):
            pass
        else:
            self.stats2 = StatsPopup(path)
            self.stats2.start()

    def aboutClicked(self):
        """
        When button pushed, pops up
        a frame with a text read from
        a file
        """
        text = []
        file = open("/opt/Despeckle_pyqt/about.txt", 'r')
        for line in file:
            text.append(line)

        self.about = MyPopup("about")
        self.about.setText("".join(text))
예제 #29
0
    scriptdir = dirname(realpath(sys.executable))
    if not scriptdir.endswith('/bin') and not scriptdir.endswith('/MacOS'):
        scriptdir = realpath(os.path.join(scriptdir, ".."))
    scriptdirs = [scriptdir]
else:
    scriptdir = dirname(realpath(sys.argv[0]))
    scriptdir1 = realpath(join(scriptdir, '..', '..', 'ReadCounts', 'src'))
    scriptdirs = [scriptdir, scriptdir1]

try:
    scriptextn = "." + os.path.split(sys.argv[0])[1].rsplit('.', 1)[1]
except:
    scriptextn = ""

from execute import Execute
execprog = Execute(*scriptdirs, extn=scriptextn)

from release import RELEASE, VERSION
VERSION = "%s (%s:%s)" % (VERSION, RELEASE, VERSION)


def excepthook(etype, value, tb):
    traceback.print_exception(etype, value, tb)
    print("Type <Enter> to Exit...", end=' ', file=sys.stderr)
    sys.stderr.flush()
    input()


toremove = []

예제 #30
0
 def ButtonClicked(self, widget, Exec):
     self.mintMenuWin.hide()
     if Exec:
         Execute(Exec)
예제 #31
0
    def handle(self, cmd, json_data, filedata=None):
        #python 3 conversion
        #cmd = cmd.decode('ascii')
        print("[INFO] Command sent:" + str(cmd))
        res = {}
        try:
            # pdb.set_trace()
            browserdata = {
                'remote_ip': self.request.remote_ip,
                'browser': self.request.headers.get('User-Agent')
            }
            Log.i(browserdata)
            # Python 3 conversion needed.
            #pdb.set_trace()
            lang = json_data.get('lang', 'C')
            name = json_data.get('name', 'Solution')
            code = json_data.get('code', '')
            input = json_data.get('input', '')
            depends = json_data.get('depends', '')
            testcases = json_data.get('testcases', '')
            func = ''

            # Unicode
            #[ cmd, lang, name, code, input, depends] = [ xx.encode('utf8') if xx else '' for xx in [ cmd, lang, name, code, input, depends]]
            # Logic  Here ..
            try:
                #pdb.set_trace()
                if cmd == 'compile':
                    res = Execute(lang, name, code, func, input, depends,
                                  testcases).save(name, code, func,
                                                  input).compile(name)
                elif cmd == 'run':
                    res = Execute(lang, name, code, func, input, depends,
                                  testcases).save(name, code, func,
                                                  input).fullrun(name)
                elif cmd == 'crashbt':
                    res = Execute(lang, name, code, func, input, depends,
                                  testcases).getCrashBackTrace()
                elif cmd == 'mleaks':
                    res = Execute(lang, name, code, func, input, depends,
                                  testcases).getMemoryleaks()
                elif cmd == 'perf':
                    res = Execute(lang, name, code, func, input, depends,
                                  testcases).testperf(name)
                else:
                    res = {
                        'status': 'error',
                        'msg': 'Invalid cmd send to codestudio',
                        'help': 'valid command : run | compile | debug |'
                    }
            except Exception as e:
                LE(e)
                res = {
                    'status': 'error',
                    'msg':
                    'Internal error occure with codestudio. Please contact ddutta',
                    'sys_error': str(e)
                }
        except Exception as e:
            LE(e)
            res['status'] = 'error'
            res['msg'] = 'Some internal Error'
            res['help'] = 'Talk to dev ops:' + str(e)

        #self.write(json.dumps(res, default=json_util.default))
        self.write(json.dumps(res))