Esempio n. 1
0
	def checkValidInputs(self):
		ErrorMessage = ""
		# check that beam energy can be converted to non-negative float format (from string format)
		ErrorMessage += checks(self.energy,'beam energy',False).checkIfNonNegFloat()

		# check that beam flux can be converted to float format (from string format)
		ErrorMessage += checks(self.flux,'beam flux',False).checkIfNonNegFloat()

		return ErrorMessage
Esempio n. 2
0
    def checkValidInputs(self):
        ErrorMessage = ""
        # check that beam energy can be converted to non-negative float format (from string format)
        ErrorMessage += checks(self.energy, 'beam energy',
                               False).checkIfNonNegFloat()

        # check that beam flux can be converted to float format (from string format)
        ErrorMessage += checks(self.flux, 'beam flux',
                               False).checkIfNonNegFloat()

        return ErrorMessage
Esempio n. 3
0
	def checkValidInputs_subclass(self):
		ErrorMessage = ""

		if len(self.collimation) != 2:
			ErrorMessage += 'Rectangular collimation requires two inputs (horizontal and vertical).\n'
		else:
			# check that beam collimation can be converted to non-negative float format (from string format)
			ErrorMessage += checks(self.collimation[0],'horizontal (x) collimation',False).checkIfNonNegFloat()
			ErrorMessage += checks(self.collimation[1],'vertical (y) collimation',False).checkIfNonNegFloat()

		return ErrorMessage
Esempio n. 4
0
	def checkValidInputs_subclass(self):
		ErrorMessage = ""

		if len(self.pixelSize) != 2:
			ErrorMessage += 'Pixel size requires two inputs (horizontal and vertical).\n'
		else:
			# check that beam pixelSize can be converted to non-negative float format (from string format)
			ErrorMessage += checks(self.pixelSize[0],'horizontal (x) pixel size',False).checkIfNonNegFloat()
			ErrorMessage += checks(self.pixelSize[1],'vertical (y) pixel size',False).checkIfNonNegFloat()

		# check that beam file name has been entered correctly
		ErrorMessage += checks(self.file,'Beam file',False).checkIfNonBlankString()

		return ErrorMessage
Esempio n. 5
0
    def checkValidInputs_subclass(self):
        ErrorMessage = ""

        if len(self.collimation) != 2:
            ErrorMessage += 'Rectangular collimation requires two inputs (horizontal and vertical).\n'
        else:
            # check that beam collimation can be converted to non-negative float format (from string format)
            ErrorMessage += checks(self.collimation[0],
                                   'horizontal (x) collimation',
                                   False).checkIfNonNegFloat()
            ErrorMessage += checks(self.collimation[1],
                                   'vertical (y) collimation',
                                   False).checkIfNonNegFloat()

        return ErrorMessage
Esempio n. 6
0
    def run(self):
        agentLogger = logging.getLogger('agent')

        agentLogger.debug('Collecting basic system stats')

        # Get some basic system stats to post back for development/testing
        import platform

        # platform.python_version() doesn't work in IronPython in 2.6: http://bugs.python.org/issue6388
        systemStats = {'machine': platform.machine(), 'platform': 'windows', 'processor': platform.processor(),
                       'pythonV': sys.version,
                       'cpuCores': int(sum(mo.GetPropertyValue('NumberOfCores') for mo in ManagementClass(
                               'Win32_Processor').GetInstances().GetEnumerator())) }

        systemStats['winV'] = ManagementClass('Win32_OperatingSystem').GetInstances().GetEnumerator().next(
                ).GetPropertyValue('Version')

        agentLogger.debug('System: ' + str(systemStats))

        # We use the system stats in the log but user might not want them posted back
        if 'reportAnonStats' in agentConfig and agentConfig['reportAnonStats'] == 'no':
            systemStats = None

        agentLogger.debug('Creating checks instance')

        # Checks instance
        c = checks(agentConfig)

        # Schedule the checks
        agentLogger.debug('Scheduling checks every ' + str(agentConfig['checkFreq']) + ' seconds')
        s = sched.scheduler(time.time, time.sleep)
        c.doChecks(s, True, systemStats) # start immediately (case 28315)
        s.run()
Esempio n. 7
0
	def run(self):	
		mainLogger.debug('Collecting basic system stats')
		
		# Get some basic system stats to post back for development/testing
		import platform
		systemStats = {'machine': platform.machine(), 'platform': sys.platform, 'processor': platform.processor(), 'pythonV': platform.python_version(), 'cpuCores': self.cpuCores()}
		
		if sys.platform == 'linux2':
			systemStats['nixV'] = platform.dist()
			
		elif sys.platform == 'darwin':
			systemStats['macV'] = platform.mac_ver()
			
		elif sys.platform.find('freebsd') != -1:
			version = platform.uname()[2]
			systemStats['fbsdV'] = ('freebsd', version, '') # no codename for FreeBSD
		
		mainLogger.info('System: ' + str(systemStats))
						
		mainLogger.debug('Creating checks instance')
		
		# Checks instance
		c = checks(agentConfig, rawConfig, mainLogger)
		
		# Schedule the checks
		mainLogger.info('checkFreq: %s', agentConfig['checkFreq'])
		s = sched.scheduler(time.time, time.sleep)
		c.doChecks(s, True, systemStats) # start immediately (case 28315)
		s.run()
Esempio n. 8
0
	def run(self):	
		mainLogger.debug('Collecting basic system stats')
		
		# Get some basic system stats to post back for development/testing
		import platform
		systemStats = {'machine': platform.machine(), 'platform': sys.platform, 'processor': platform.processor(), 'pythonV': platform.python_version(), 'cpuCores': self.cpuCores()}
		
		if sys.platform == 'linux2':
			systemStats['nixV'] = platform.dist()
			
		elif sys.platform == 'darwin':
			systemStats['macV'] = platform.mac_ver()
			
		elif sys.platform.find('freebsd') != -1:
			version = platform.uname()[2]
			systemStats['fbsdV'] = ('freebsd', version, '') # no codename for FreeBSD
		
		mainLogger.info('System: ' + str(systemStats))
						
		mainLogger.debug('Creating checks instance')
		
		# Checks instance
		c = checks(agentConfig, rawConfig, mainLogger)
		
		# Schedule the checks
		mainLogger.info('checkFreq: %s', agentConfig['checkFreq'])
		s = sched.scheduler(time.time, time.sleep)
		c.doChecks(s, True, systemStats) # start immediately (case 28315)
		s.run()
Esempio n. 9
0
	def run(self):	
		agentLogger = logging.getLogger('agent')
		
		agentLogger.debug('Collecting basic system stats')
		
		# Get some basic system stats to post back for development/testing
		import platform
		systemStats = {'machine': platform.machine(), 'platform': sys.platform, 'processor': platform.processor(), 'pythonV': platform.python_version(), 'cpuCores': self.cpuCores()}
		
		if sys.platform == 'linux2':			
			systemStats['nixV'] = platform.dist()
			
		elif sys.platform == 'darwin':
			systemStats['macV'] = platform.mac_ver()
		
		agentLogger.debug('System: ' + str(systemStats))
						
		agentLogger.debug('Creating checks instance')
		
		# Checks instance
		c = checks(agentConfig)
		
		# Schedule the checks
		agentLogger.debug('Scheduling checks every ' + str(agentConfig['checkFreq']) + ' seconds')
		s = sched.scheduler(time.time, time.sleep)
		c.doChecks(s, True, systemStats) # start immediately (case 28315)
		s.run()
Esempio n. 10
0
	def run(self):	
		agentLogger = logging.getLogger('agent')
		
		agentLogger.debug('Collecting basic system stats')
		
		# Get some basic system stats to post back for development/testing
		import platform
		systemStats = {'machine': platform.machine(), 'platform': sys.platform, 'processor': platform.processor(), 'pythonV': platform.python_version()}
		
		if sys.platform == 'linux2':			
			systemStats['nixV'] = platform.dist()
			
		elif sys.platform == 'darwin':
			systemStats['macV'] = platform.mac_ver()
		
		agentLogger.debug('System: ' + str(systemStats))
		
		# We use the system stats in the log but user might not want them posted back
		if 'reportAnonStats' in agentConfig and agentConfig['reportAnonStats'] == 'no':	
			systemStats = None
				
		agentLogger.debug('Creating checks instance')
		
		# Checks instance
		c = checks(agentConfig)
		
		# Schedule the checks
		agentLogger.debug('Scheduling checks every ' + str(agentConfig['checkFreq']) + ' seconds')
		s = sched.scheduler(time.time, time.sleep)
		c.doChecks(s, True, systemStats)
		s.run()
Esempio n. 11
0
    def checkValidInputs_subclass(self):
        ErrorMessage = ""

        if len(self.pixelSize) != 2:
            ErrorMessage += 'Pixel size requires two inputs (horizontal and vertical).\n'
        else:
            # check that beam pixelSize can be converted to non-negative float format (from string format)
            ErrorMessage += checks(self.pixelSize[0],
                                   'horizontal (x) pixel size',
                                   False).checkIfNonNegFloat()
            ErrorMessage += checks(self.pixelSize[1],
                                   'vertical (y) pixel size',
                                   False).checkIfNonNegFloat()

        # check that beam file name has been entered correctly
        ErrorMessage += checks(self.file, 'Beam file',
                               False).checkIfNonBlankString()

        return ErrorMessage
Esempio n. 12
0
    def run(self):
        mainLogger.debug('Collecting basic system stats')

        # Get some basic system stats to post back for development/testing
        systemStats = {
            'machine': platform.machine(),
            'platform': sys.platform,
            'processor': platform.processor(),
            'pythonV': platform.python_version(),
            'cpuCores': cpu_cores()
        }

        if sys.platform == 'linux2':
            systemStats['nixV'] = platform.dist()

        elif sys.platform == 'darwin':
            systemStats['macV'] = platform.mac_ver()

        elif sys.platform.find('freebsd') != -1:
            version = platform.uname()[2]
            systemStats['fbsdV'] = ('freebsd', version, ''
                                    )  # no codename for FreeBSD

        mainLogger.info('System: ' + str(systemStats))

        # Log tailer
        if agentConfig.get('logTailPaths', '') != '':

            from logtail import LogTailer

            logFiles = []

            for path in agentConfig['logTailPaths'].split(','):
                files = glob.glob(path)

                for file in files:
                    logFiles.append(file)

            for file in logFiles:
                mainLogger.info('Starting log tailer: %s', file)

                logThread = LogTailer(agentConfig, mainLogger, file)
                logThread.setName(file)
                logThread.start()

        # Checks instance
        mainLogger.debug('Creating checks instance')
        c = checks(agentConfig, rawConfig, mainLogger)

        # Schedule the checks
        mainLogger.info('checkFreq: %s', agentConfig['checkFreq'])
        s = sched.scheduler(time.time, time.sleep)
        c.doChecks(s, True, systemStats)  # start immediately (case 28315)
        s.run()
Esempio n. 13
0
	def checkValidInputs_subclass(self):
		ErrorMessage = ""

		# check valid pdb code input
		if len(self.pdb) != 4:
			ErrorMessage += 'PDB code input {} not of compatible format.\n'.format(str(self.pdb))

		# check that crystal solventHeavyConc formatting is correct
		ErrorMessage += checks(self.solventHeavyConc,'solvent heavy atom concentration',True).checkHeavyAtomFormat()

		return ErrorMessage
Esempio n. 14
0
    def run(self):
        mainLogger.debug('Collecting basic system stats')

        # Get some basic system stats to post back for development/testing
        systemStats = {
            'machine': platform.machine(),
            'platform': sys.platform,
            'processor': platform.processor(),
            'pythonV': platform.python_version(),
            'cpuCores': cpu_cores()
        }

        if sys.platform == 'linux2':
            systemStats['nixV'] = platform.dist()

        elif sys.platform == 'darwin':
            systemStats['macV'] = platform.mac_ver()

        elif sys.platform.find('freebsd') != -1:
            version = platform.uname()[2]
            systemStats['fbsdV'] = ('freebsd', version, '')  # no codename for FreeBSD

        mainLogger.info('System: ' + str(systemStats))

        # Log tailer
        if agentConfig.get('logTailPaths', '') != '':

            from logtail import LogTailer

            logFiles = []

            for path in agentConfig['logTailPaths'].split(','):
                files = glob.glob(path)

                for file in files:
                    logFiles.append(file)

            for file in logFiles:
                mainLogger.info('Starting log tailer: %s', file)

                logThread = LogTailer(agentConfig, mainLogger, file)
                logThread.setName(file)
                logThread.start()

        # Checks instance
        mainLogger.debug('Creating checks instance')
        c = checks(agentConfig, rawConfig, mainLogger)

        # Schedule the checks
        mainLogger.info('checkFreq: %s', agentConfig['checkFreq'])
        s = sched.scheduler(time.time, time.sleep)
        c.doChecks(s, True, systemStats)  # start immediately (case 28315)
        s.run()
Esempio n. 15
0
    def checkValidInputs_subclass(self):
        ErrorMessage = ""

        # check valid pdb code input
        if len(self.pdb) != 4:
            ErrorMessage += 'PDB code input {} not of compatible format.\n'.format(
                str(self.pdb))

        # check that crystal solventHeavyConc formatting is correct
        ErrorMessage += checks(self.solventHeavyConc,
                               'solvent heavy atom concentration',
                               True).checkHeavyAtomFormat()

        return ErrorMessage
Esempio n. 16
0
    def run(self):
        agentLogger = logging.getLogger("agent")

        agentLogger.debug("Collecting basic system stats")

        # Get some basic system stats to post back for development/testing
        import platform

        systemStats = {
            "machine": platform.machine(),
            "platform": sys.platform,
            "processor": platform.processor(),
            "pythonV": platform.python_version(),
        }

        if sys.platform == "linux2":
            systemStats["nixV"] = platform.dist()

        elif sys.platform == "darwin":
            systemStats["macV"] = platform.mac_ver()

        agentLogger.debug("System: " + str(systemStats))

        # We use the system stats in the log but user might not want them posted back
        if "reportAnonStats" in agentConfig and agentConfig["reportAnonStats"] == "no":
            systemStats = None

        agentLogger.debug("Creating checks instance")

        # Checks instance
        c = checks(agentConfig)

        # Schedule the checks
        agentLogger.debug("Scheduling checks every " + str(agentConfig["checkFreq"]) + " seconds")
        s = sched.scheduler(time.time, time.sleep)
        c.doChecks(s, True, systemStats)  # start immediately (case 28315)
        s.run()
Esempio n. 17
0
    def run(self):
        mainLogger.debug("Collecting basic system stats")

        # Get some basic system stats to post back for development/testing
        import platform

        systemStats = {
            "machine": platform.machine(),
            "platform": sys.platform,
            "processor": platform.processor(),
            "pythonV": platform.python_version(),
            "cpuCores": self.cpuCores(),
        }

        if sys.platform == "linux2":
            systemStats["nixV"] = platform.dist()

        elif sys.platform == "darwin":
            systemStats["macV"] = platform.mac_ver()

        elif sys.platform.find("freebsd") != -1:
            version = platform.uname()[2]
            systemStats["fbsdV"] = ("freebsd", version, "")  # no codename for FreeBSD

        mainLogger.info("System: " + str(systemStats))

        mainLogger.debug("Creating checks instance")

        # Checks instance
        c = checks(agentConfig, rawConfig, mainLogger)

        # Schedule the checks
        mainLogger.info("checkFreq: %s", agentConfig["checkFreq"])
        s = sched.scheduler(time.time, time.sleep)
        c.doChecks(s, True, systemStats)  # start immediately (case 28315)
        s.run()
Esempio n. 18
0
	def checkValidInputs(self):
		ErrorMessage = ""
		# check valid crystal type
		crystalType = str(self.type).lower()
		if crystalType not in ('cuboid','spherical','cylindrical','polyhedron'):
			ErrorMessage += 'Crystal type {} not of compatible format.\n'.format(str(self.type))

		# check that relevant crystal dimensions (dependent of crystal type) can be converted to 
		# non-negative float format (from string format)
		if crystalType in ('cuboid','spherical','cylindrical'):
			ErrorMessage += checks(self.crystDimX,'x dimension',False).checkIfNonNegFloat()
		if crystalType in ('cuboid','cylindrical'):
			ErrorMessage += checks(self.crystDimY,'y dimension',False).checkIfNonNegFloat()
		if crystalType in ('cuboid'):
			ErrorMessage += checks(self.crystDimZ,'z dimension',False).checkIfNonNegFloat()
		if crystalType in ('polyhedron'):
			ErrorMessage += checks(self.modelFile,'model file',False).checkIfNonBlankString()
			if str(self.wireFrameType).lower() != 'obj':
				ErrorMessage += 'Wire frame type not of compatible .obj format\n'

		# check that crystal pixelsPerMicron can be converted to non-negative float format (from string format)
		ErrorMessage += checks(self.pixelsPerMicron,'pixels per micron',False).checkIfNonNegFloat()

		# check that crystal angle P and angle L can be converted to float format (from string format)
		ErrorMessage += checks(self.angleP,'angle P',True).checkIfFloat()
		ErrorMessage += checks(self.angleL,'angle L',True).checkIfFloat()

		# check that absCoefCalc value of valid form
		if str(self.absCoefCalc).lower() not in ('average','exp','rd3d','rdv2','sequence','saxs','saxsseq'):
			ErrorMessage += 'Crystal absorption coefficient {} not of compatible format.\n'.format(str(self.absCoefCalc))

		# check container information is valid (if present)
		try:
			self.containerMaterialType
			# check that container type of suitable format
			if str(self.containerMaterialType).lower() not in ('mixture','elemental','none'):
				ErrorMessage += 'Crystal container type {} not of compatible format.\n'.format(str(self.containerMaterialType))

			# check that container thickness can be converted to float and is non-negative
			ErrorMessage += checks(self.containerThickness,'container thickness',False).checkIfNonNegFloat()

			# check that container density can be converted to float and is non-negative
			ErrorMessage += checks(self.containerDensity,'container density',False).checkIfNonNegFloat()

			# check that if 'mixture' type specified, then corresponding mixture is a non-empty string
			if str(self.containerMaterialType).lower() == 'mixture':
				if not isinstance(self.materialMixture, basestring):
					ErrorMessage += 'Crystal container mixture not of compatible string format.\n'
				elif len(self.materialMixture) == 0:
					ErrorMessage += 'Crystal container mixture field is blank.\n'

			# check that if 'elemental' type specified, then corresponding element composition is a non-empty string
			if str(self.containerMaterialType).lower() == 'elemental':
				if not isinstance(self.materialElements, basestring):
					ErrorMessage += 'Crystal container elemental composition not of compatible string format.\n'
				elif len(self.materialElements) == 0:
					ErrorMessage += 'Crystal container elemental composition field is blank.\n'
				else:
					# check that suitable heavy atom string formatting
					ErrorMessage += checks(self.materialElements,'material elemental composition',False).checkHeavyAtomFormat()
		except AttributeError:
			pass

		return ErrorMessage
Esempio n. 19
0
def main():
    """
    Main Run Selection script
    """

    # Define arguments
    parser = argparse.ArgumentParser()
    parser.add_argument('--date',
                        '-d',
                        type=str,
                        default='',
                        dest='date',
                        required=False,
                        help='The date of the RS shift, in dd/mm/yyyy format.')
    parser.add_argument('--name',
                        '-n',
                        type=str,
                        default='',
                        dest='name',
                        required=False,
                        help='The name associated with the RS shift.')
    parser.add_argument('--run',
                        '-r',
                        type=int,
                        default=None,
                        dest='run_number',
                        required=False,
                        help='The target run number.')
    parser.add_argument('--range',
                        '-R',
                        type=list,
                        default=[100000, 100001],
                        dest='range',
                        required=False,
                        help='The date of the RS shift, in dd/mm/yyyy format.')
    parser.add_argument('--type',
                        '-t',
                        type=str,
                        default='physics',
                        dest='run_type',
                        required=False,
                        help='The run type.')
    parser.add_argument('--logfile',
                        '-l',
                        type=str,
                        default='run_selection',
                        dest='logfile',
                        required=False,
                        help='The log file.')

    # Parse arguments
    args = parser.parse_args()
    print(args)
    # return 0

    # Print the arguments back to the user as confirmation

    # Initialize the program
    # date = datetime.strptime(args.date, '%d/%m/%Y')

    # Call the checks
    print(checks.checks(args))
Esempio n. 20
0
    def __init__\
        ( self
        , config
        , checks = None
        , ngram_source=None
        ):

        self.config = config
        self.checks = checks
        self.ngram_source = ngram_source

        self.symbols = parse_symbols(unicode(config.LAYOUT))
        self.costs = parse_symbols(unicode(config.COSTS))[0]
        self.rows = parse_symbols(unicode(config.ROWS))[0]
        self.cols = parse_symbols(unicode(config.COLS))[0]
        self.fingers = parse_symbols(unicode(config.FINGERS))[0]
        self.unbalancing_positions = parse_symbols(unicode(config.UNBALANCING_POSITIONS))[0]
        self.mutatable_positions = parse_symbols(unicode(config.LAYOUT), column = 1)
        self.layers = []

        self._possible_permutations = list()
        self.permutation_history = list()
        self.mutatable_keys = []
        self.lookup = LayoutLookup(config, self)

        # parse layer infos
        lines = config.LAYOUT.split('\n')
        for line in lines:
            line = line.strip()
            if line.startswith(u'Layer'):
                layer = dict()
                layer['name'] = re.match("^Layer (.*)[^ ]*", line).groups()[0]
                layer['modifier_symbols'] = list()
                if re.match(".*\[(.*)\].*", line) is not None:
                    layer['modifier_symbols'] = list(re.match(".*\[(.*)\].*", line).groups()[0])
                self.layers.append(layer)


        # create lookup keys
        z = -1
        for layer in self.symbols:
            z += 1
            y = -1
            self.mutatable_keys.append([])
            for row in layer:
                y += 1
                x = -1
                for symbol in row:
                    x += 1
                    if symbol == '':
                        continue

                    hand = None
                    finger = None
                    if self.fingers[y][x] != '':
                        hand = self.fingers[y][x][:1]
                        finger = int(self.fingers[y][x][1:])
                    elif True:
                        print ">>>> %s (%s %s)" % (symbol, y, x)
                    unbalancing = self.unbalancing_positions[y][x] == '.'
                    mutatable = self.mutatable_positions[z][y][x] == '.'

                    layout_key = LayoutKey(self)
                    layout_key.symbol = symbol
                    layout_key.x = x
                    layout_key.y = y
                    layout_key.row = int(self.rows[y][x]) if self.rows[y][x] != '' else None
                    layout_key.col = int(self.cols[y][x]) if self.cols[y][x] != '' else None
                    layout_key.layer = z
                    layout_key.hand = hand
                    layout_key.finger = finger
                    layout_key.unbalancing = unbalancing
                    layout_key.mutatable = mutatable
                    layout_key.pos_cost = float(self.costs[y][x]) if self.costs[y][x] != '' else None

                    if mutatable:
                        self.mutatable_keys[z].append(layout_key)

                    self.lookup.add(layout_key)


        # create list of possible mutations
        for z in range(0, len(self.symbols)):
            if len(self._possible_permutations) <= z:
                self._possible_permutations.append([])

            for a_key in self.mutatable_keys[z]:
                for b_key in self.mutatable_keys[z]:
                    if a_key != b_key and (b_key, a_key) not in self._possible_permutations[z]:
                        self._possible_permutations[z].append((a_key, b_key))

        # create ngramm list
        if self.ngram_source is None:
            ngram_source = read_ngrams(config)

        self.ngrams = list()
        for i in range(0, 3):
            ngram_keys = list()
            ngram_freqs = list()
            for ngram in ngram_source[i][:self.config.NGRAM_LIMITS[i]]:
                keys = list()
                for symbol in ngram[0]:
                    keys.append(self.lookup.get(symbol))
                ngram_keys.append(keys)
                ngram_freqs.append(ngram[1])
            self.ngrams.append(zip(ngram_keys, ngram_freqs))
            #print "done with %i-grams" % (i + 1)

        self.total_check_weight = 0
        self.optimization_score = 0

        import checks as lib_checks
        if self.checks is None:
            self.checks = lib_checks.checks()

        # after we added all keys to the layout, add
        # 'modifier_keys' to layout.layers
        for layer in self.layers:
            mod_left = list()
            mod_right = list()
            for symbol in layer['modifier_symbols']:
                for key in self.lookup.get_all(symbol):
                    if key.layer == 0 and key.hand == 'L':
                        mod_left.append(key)
                    if key.layer == 0 and key.hand == 'R':
                        mod_right.append(key)
            layer['modifier_keys'] = dict\
                ( L = mod_left
                , R = mod_right
                )
Esempio n. 21
0
    def checkValidInputs_subclass(self):
        ErrorMessage = ""

        # check that unit cell dimensions can be converted to non-negative float format (from string format)
        ErrorMessage += checks(self.unitcell_a, 'unit cell a dimension',
                               False).checkIfNonNegFloat()
        ErrorMessage += checks(self.unitcell_b, 'unit cell b dimension',
                               False).checkIfNonNegFloat()
        ErrorMessage += checks(self.unitcell_c, 'unit cell c dimension',
                               False).checkIfNonNegFloat()
        ErrorMessage += checks(self.unitcell_alpha, 'unit cell angle alpha',
                               True).checkIfNonNegFloat()
        ErrorMessage += checks(self.unitcell_beta, 'unit cell angle beta',
                               True).checkIfNonNegFloat()
        ErrorMessage += checks(self.unitcell_gamma, 'unit cell angle gamma',
                               True).checkIfNonNegFloat()

        # check that protein concentration can be converted to non-negative float format (from string)
        ErrorMessage += checks(self.proteinConc, 'protein concentration',
                               False).checkIfNonNegFloat()

        # check that crystal proteinHeavyAtoms formatting is correct
        ErrorMessage += checks(self.proteinHeavyAtoms,
                               'heavy atoms in protein',
                               True).checkHeavyAtomFormat()

        # check that crystal solventHeavyConc formatting is correct
        ErrorMessage += checks(self.solventHeavyConc,
                               'solvent heavy atom concentration',
                               True).checkHeavyAtomFormat()

        # check that solvent fraction is float between 0 and 1
        ErrorMessage += checks(self.solventFraction, 'solvent fraction',
                               True).checkIfFloatBetween01()

        # check that sequence file name has been entered
        ErrorMessage += checks(self.seqFile, 'sequence file',
                               False).checkIfNonBlankString()

        return ErrorMessage
Esempio n. 22
0
    def checkValidInputs_subclass(self):
        ErrorMessage = ""

        # check that unit cell dimensions can be converted to non-negative float format (from string format)
        ErrorMessage += checks(self.unitcell_a, 'unit cell a dimension',
                               False).checkIfNonNegFloat()
        ErrorMessage += checks(self.unitcell_b, 'unit cell b dimension',
                               False).checkIfNonNegFloat()
        ErrorMessage += checks(self.unitcell_c, 'unit cell c dimension',
                               False).checkIfNonNegFloat()
        ErrorMessage += checks(self.unitcell_alpha, 'unit cell angle alpha',
                               True).checkIfNonNegFloat()
        ErrorMessage += checks(self.unitcell_beta, 'unit cell angle beta',
                               True).checkIfNonNegFloat()
        ErrorMessage += checks(self.unitcell_gamma, 'unit cell angle gamma',
                               True).checkIfNonNegFloat()

        # check that protein concentration can be converted to non-negative float format (from string)
        ErrorMessage += checks(self.proteinConc, 'protein concentration',
                               False).checkIfNonNegFloat()

        # check that number of residues has been filled in and can be converted to a non-negative integer
        ErrorMessage += checks(self.numResidues, 'number of residues',
                               False).checkIfNonNegInt()

        # check that number of RNA/DNA nucleotides can be converted to non-negative integers
        ErrorMessage += checks(self.numRNA, 'number of RNA nucleotides',
                               True).checkIfNonNegInt()
        ErrorMessage += checks(self.numDNA, 'number of DNA nucleotides',
                               True).checkIfNonNegInt()

        # check that crystal proteinHeavyAtoms formatting is correct
        ErrorMessage += checks(self.proteinHeavyAtoms,
                               'heavy atoms in protein',
                               True).checkHeavyAtomFormat()

        # check that crystal solventHeavyConc formatting is correct
        ErrorMessage += checks(self.solventHeavyConc,
                               'solvent heavy atom concentration',
                               True).checkHeavyAtomFormat()

        # check that solvent fraction is float between 0 and 1
        ErrorMessage += checks(self.solventFraction, 'solvent fraction',
                               True).checkIfFloatBetween01()

        return ErrorMessage
Esempio n. 23
0
    def checkValidInputs(self):
        ErrorMessage = ""
        # check valid crystal type
        crystalType = str(self.type).lower()
        if crystalType not in ('cuboid', 'spherical', 'cylindrical',
                               'polyhedron'):
            ErrorMessage += 'Crystal type {} not of compatible format.\n'.format(
                str(self.type))

        # check that relevant crystal dimensions (dependent of crystal type) can be converted to
        # non-negative float format (from string format)
        if crystalType in ('cuboid', 'spherical', 'cylindrical'):
            ErrorMessage += checks(self.crystDimX, 'x dimension',
                                   False).checkIfNonNegFloat()
        if crystalType in ('cuboid', 'cylindrical'):
            ErrorMessage += checks(self.crystDimY, 'y dimension',
                                   False).checkIfNonNegFloat()
        if crystalType in ('cuboid'):
            ErrorMessage += checks(self.crystDimZ, 'z dimension',
                                   False).checkIfNonNegFloat()
        if crystalType in ('polyhedron'):
            ErrorMessage += checks(self.modelFile, 'model file',
                                   False).checkIfNonBlankString()
            if str(self.wireFrameType).lower() != 'obj':
                ErrorMessage += 'Wire frame type not of compatible .obj format\n'

        # check that crystal pixelsPerMicron can be converted to non-negative float format (from string format)
        ErrorMessage += checks(self.pixelsPerMicron, 'pixels per micron',
                               False).checkIfNonNegFloat()

        # check that crystal angle P and angle L can be converted to float format (from string format)
        ErrorMessage += checks(self.angleP, 'angle P', True).checkIfFloat()
        ErrorMessage += checks(self.angleL, 'angle L', True).checkIfFloat()

        # check that absCoefCalc value of valid form
        if str(self.absCoefCalc).lower() not in ('average', 'exp', 'rd3d',
                                                 'rdv2', 'sequence', 'saxs',
                                                 'saxsseq'):
            ErrorMessage += 'Crystal absorption coefficient {} not of compatible format.\n'.format(
                str(self.absCoefCalc))

        # check container information is valid (if present)
        try:
            self.containerMaterialType
            # check that container type of suitable format
            if str(self.containerMaterialType).lower() not in ('mixture',
                                                               'elemental',
                                                               'none'):
                ErrorMessage += 'Crystal container type {} not of compatible format.\n'.format(
                    str(self.containerMaterialType))

            # check that container thickness can be converted to float and is non-negative
            ErrorMessage += checks(self.containerThickness,
                                   'container thickness',
                                   False).checkIfNonNegFloat()

            # check that container density can be converted to float and is non-negative
            ErrorMessage += checks(self.containerDensity, 'container density',
                                   False).checkIfNonNegFloat()

            # check that if 'mixture' type specified, then corresponding mixture is a non-empty string
            if str(self.containerMaterialType).lower() == 'mixture':
                if not isinstance(self.materialMixture, basestring):
                    ErrorMessage += 'Crystal container mixture not of compatible string format.\n'
                elif len(self.materialMixture) == 0:
                    ErrorMessage += 'Crystal container mixture field is blank.\n'

            # check that if 'elemental' type specified, then corresponding element composition is a non-empty string
            if str(self.containerMaterialType).lower() == 'elemental':
                if not isinstance(self.materialElements, basestring):
                    ErrorMessage += 'Crystal container elemental composition not of compatible string format.\n'
                elif len(self.materialElements) == 0:
                    ErrorMessage += 'Crystal container elemental composition field is blank.\n'
                else:
                    # check that suitable heavy atom string formatting
                    ErrorMessage += checks(self.materialElements,
                                           'material elemental composition',
                                           False).checkHeavyAtomFormat()
        except AttributeError:
            pass

        return ErrorMessage
Esempio n. 24
0
    def checkValidInputs(self):
        ErrorMessage = ""

        # check that wedge angular start & stop can be converted to float format (from string format)
        ErrorMessage += checks(self.angStart, 'wedge start',
                               False).checkIfFloat()
        ErrorMessage += checks(self.angStop, 'wedge start',
                               False).checkIfFloat()

        # check that wedge angular start < stop
        try:
            if float(self.angStart) > float(self.angStop):
                ErrorMessage += 'Wedge angular start greater than stop value.\n'
        except ValueError:
            pass

        # check that wedge exposure time can be converted to float format (from string format), and is positive
        ErrorMessage += checks(self.exposureTime, 'exposure time',
                               False).checkIfNonNegFloat()

        # check that wedge angular resolution can be converted to float format (from string format), and is positive
        ErrorMessage += checks(self.angularResolution, 'angular resolution',
                               True).checkIfNonNegFloat()

        # check that start offset values can be converted to float format (from string format)
        ErrorMessage += checks(self.startOffsetList[0], 'start x off set',
                               True).checkIfFloat()
        ErrorMessage += checks(self.startOffsetList[1], 'start y off set',
                               True).checkIfFloat()
        ErrorMessage += checks(self.startOffsetList[2], 'start z off set',
                               True).checkIfFloat()

        # check that translation per degree can be converted to float format (from string format)
        ErrorMessage += checks(self.transPerDegList[0],
                               'x translation per degree',
                               True).checkIfFloat()
        ErrorMessage += checks(self.transPerDegList[1],
                               'y translation per degree',
                               True).checkIfFloat()
        ErrorMessage += checks(self.transPerDegList[2],
                               'z translation per degree',
                               True).checkIfFloat()

        # check that rotation offset can be converted to float format (from string format)
        ErrorMessage += checks(self.rotAxBeamOffset, 'rotation offset',
                               True).checkIfFloat()

        return ErrorMessage
Esempio n. 25
0
	def checkValidInputs_subclass(self):
		ErrorMessage = ""

		# check that unit cell dimensions can be converted to non-negative float format (from string format)
		ErrorMessage += checks(self.unitcell_a,'unit cell a dimension',False).checkIfNonNegFloat()
		ErrorMessage += checks(self.unitcell_b,'unit cell b dimension',False).checkIfNonNegFloat()
		ErrorMessage += checks(self.unitcell_c,'unit cell c dimension',False).checkIfNonNegFloat()
		ErrorMessage += checks(self.unitcell_alpha,'unit cell angle alpha',True).checkIfNonNegFloat()
		ErrorMessage += checks(self.unitcell_beta,'unit cell angle beta',True).checkIfNonNegFloat()
		ErrorMessage += checks(self.unitcell_gamma,'unit cell angle gamma',True).checkIfNonNegFloat()

		# check that protein concentration can be converted to non-negative float format (from string)
		ErrorMessage += checks(self.proteinConc,'protein concentration',False).checkIfNonNegFloat()

		# check that crystal proteinHeavyAtoms formatting is correct
		ErrorMessage += checks(self.proteinHeavyAtoms,'heavy atoms in protein',True).checkHeavyAtomFormat()

		# check that crystal solventHeavyConc formatting is correct
		ErrorMessage += checks(self.solventHeavyConc,'solvent heavy atom concentration',True).checkHeavyAtomFormat()

		# check that solvent fraction is float between 0 and 1
		ErrorMessage += checks(self.solventFraction,'solvent fraction',True).checkIfFloatBetween01()

		# check that sequence file name has been entered
		ErrorMessage += checks(self.seqFile,'sequence file',False).checkIfNonBlankString()

		return ErrorMessage
Esempio n. 26
0
	def checkValidInputs_subclass(self):
		ErrorMessage = ""

		# check that unit cell dimensions can be converted to non-negative float format (from string format)
		ErrorMessage += checks(self.unitcell_a,'unit cell a dimension',False).checkIfNonNegFloat()
		ErrorMessage += checks(self.unitcell_b,'unit cell b dimension',False).checkIfNonNegFloat()
		ErrorMessage += checks(self.unitcell_c,'unit cell c dimension',False).checkIfNonNegFloat()
		ErrorMessage += checks(self.unitcell_alpha,'unit cell angle alpha',True).checkIfNonNegFloat()
		ErrorMessage += checks(self.unitcell_beta,'unit cell angle beta',True).checkIfNonNegFloat()
		ErrorMessage += checks(self.unitcell_gamma,'unit cell angle gamma',True).checkIfNonNegFloat()

		# check that protein concentration can be converted to non-negative float format (from string)
		ErrorMessage += checks(self.proteinConc,'protein concentration',False).checkIfNonNegFloat()

		# check that number of residues has been filled in and can be converted to a non-negative integer
		ErrorMessage += checks(self.numResidues,'number of residues',False).checkIfNonNegInt()

		# check that number of RNA/DNA nucleotides can be converted to non-negative integers
		ErrorMessage += checks(self.numRNA,'number of RNA nucleotides',True).checkIfNonNegInt()
		ErrorMessage += checks(self.numDNA,'number of DNA nucleotides',True).checkIfNonNegInt()

		# check that crystal proteinHeavyAtoms formatting is correct
		ErrorMessage += checks(self.proteinHeavyAtoms,'heavy atoms in protein',True).checkHeavyAtomFormat()

		# check that crystal solventHeavyConc formatting is correct
		ErrorMessage += checks(self.solventHeavyConc,'solvent heavy atom concentration',True).checkHeavyAtomFormat()

		# check that solvent fraction is float between 0 and 1
		ErrorMessage += checks(self.solventFraction,'solvent fraction',True).checkIfFloatBetween01()

		return ErrorMessage
def upload_file():
    '''
	Main paige of the system where student is submiting file.

	:returns: redirect to page
	:rtype: render template
	'''
    if request.method == 'POST':
        session['filename'] = 'gg'
        # kontrola loginu
        if request.form['fname'] == '':
            flash('Enter your login')
            return redirect(request.url)
        # check if the post request has the file part
        if 'file' not in request.files:
            flash('No file part')
            return redirect(request.url)
        file = request.files['file']
        # if user does not select file, browser also
        # submit a empty part without filename
        if file.filename == '':
            flash('No selected file')
            return redirect(request.url)

        if file and allowed_file(file.filename):
            session['filename'] = secure_filename(file.filename)
            # kontrola loginu
            if not checks.filename_login(session['filename'],
                                         request.form['fname']):
                flash('Inccorrect filename or not matching login')
                return redirect(request.url)

            file.save(
                os.path.join(app.config['UPLOAD_FOLDER'], session['filename']))

            session['login'] = request.form['fname']

            syn = checks.syntax_check(session['filename'])
            if syn != 0:
                flash('File cannot be compiled!')
                flash('%s' % syn)
                os.remove(constants.UPLOAD_FOLDER + '/' + session['filename'])
                return redirect(request.url)

            session['pep'] = checks.pep8_check(constants.UPLOAD_FOLDER + '/' +
                                               session['filename'])
            with open('pep.txt', 'w') as f:
                with redirect_stdout(f):
                    checks.pep8_check(constants.UPLOAD_FOLDER + '/' +
                                      session['filename'])
            helper.pep8_make_html(session['filename'])
            session['pepfile'] = session['filename'] + '-pep.html'
            session['result'] = checks.checks(
                ast2xml.convert(constants.UPLOAD_FOLDER + '/' +
                                session['filename']),
                constants.UPLOAD_FOLDER + '/' + session['filename'],
                session['filename'])

            # logovanie výsledku
            if not helper.is_List_Empty(session['result']):
                with open(
                        '/mnt/data/isj-2017-18/public/app/logs/%s.txt' %
                        str(uuid.uuid4()), 'w') as file:
                    file.write(session['filename'])
                    for item in session['result']:
                        file.write(str(item))

            session['prak'] = helper.count_odporucania(session['result'])

            return redirect(url_for('eval', name=session['login']))
        else:
            flash('Python file required')
            return redirect(request.url)
    return render_template('home.html')
Esempio n. 28
0
	def checkValidInputs(self):
		ErrorMessage = ""

		# check that wedge angular start & stop can be converted to float format (from string format)
		ErrorMessage += checks(self.angStart,'wedge start',False).checkIfFloat()
		ErrorMessage += checks(self.angStop,'wedge start',False).checkIfFloat()

		# check that wedge angular start < stop
		try:
			if float(self.angStart) > float(self.angStop):
				ErrorMessage += 'Wedge angular start greater than stop value.\n'
		except ValueError:
			pass

		# check that wedge exposure time can be converted to float format (from string format), and is positive
		ErrorMessage += checks(self.exposureTime,'exposure time',False).checkIfNonNegFloat()

		# check that wedge angular resolution can be converted to float format (from string format), and is positive
		ErrorMessage += checks(self.angularResolution,'angular resolution',True).checkIfNonNegFloat()

		# check that start offset values can be converted to float format (from string format)
		ErrorMessage += checks(self.startOffsetList[0],'start x off set',True).checkIfFloat()
		ErrorMessage += checks(self.startOffsetList[1],'start y off set',True).checkIfFloat()
		ErrorMessage += checks(self.startOffsetList[2],'start z off set',True).checkIfFloat()

		# check that translation per degree can be converted to float format (from string format)
		ErrorMessage += checks(self.transPerDegList[0],'x translation per degree',True).checkIfFloat()
		ErrorMessage += checks(self.transPerDegList[1],'y translation per degree',True).checkIfFloat()
		ErrorMessage += checks(self.transPerDegList[2],'z translation per degree',True).checkIfFloat()

		# check that rotation offset can be converted to float format (from string format)
		ErrorMessage += checks(self.rotAxBeamOffset,'rotation offset',True).checkIfFloat()

		return ErrorMessage