def scan(self, workspace, ext, db_path):
     """Scan and create the database
     ``workspace`` --root folder where robot data is scanned.
     ``ext`` --Extension for included files.
     ``db_path`` --Directory where files are saved"""
     if not os.path.exists(workspace):
         raise EnvironmentError(
             'Workspace does not exist: {0}'.format(str(workspace)))
     if not os.path.dirname(workspace):
         raise EnvironmentError(
             'Workspace must be folder: {0}'.format(str(workspace)))
     if not os.path.exists(db_path):
         os.makedirs(db_path)
     else:
         shutil.rmtree(db_path)
         os.makedirs(db_path)
     self.add_builtin()
     if self.xml_libraries:
         self.add_xml_libraries(self.xml_libraries)
     for f in finder(workspace, ext):
         self.queue.add(normalise_path(f), None, None)
     while True:
         item = self.get_item()
         if not item:
             return
         else:
             logging.info('Creating table for: {0}'.format(item[0]))
             try:
                 data = self.parse_all(item)
                 self.add_to_queue(data)
                 self.put_item_to_db(data, db_path)
             except ValueError:
                 logging.warning('Error in: %s', item[0])
             finally:
                 self.queue.set(item[0])
Example #2
0
 def scan(self, workspace, ext, db_path):
     """Scan and create the database
     ``workspace`` --root folder where robot data is scanned.
     ``ext`` --Extension for included files.
     ``db_path`` --Directory where files are saved"""
     if not os.path.exists(workspace):
         raise EnvironmentError('Workspace does not exist: {0}'.format(
             str(workspace)))
     if not os.path.dirname(workspace):
         raise EnvironmentError('Workspace must be folder: {0}'.format(
             str(workspace)))
     if not os.path.exists(db_path):
         os.makedirs(db_path)
     else:
         shutil.rmtree(db_path)
         os.makedirs(db_path)
     self.add_builtin()
     if self.xml_libraries:
         self.add_xml_libraries(self.xml_libraries)
     for f in finder(workspace, ext):
         self.queue.add(normalise_path(f), None, None)
     while True:
         item = self.get_item()
         if not item:
             return
         else:
             logging.info('Creating table for: {0}'.format(item[0]))
             try:
                 data = self.parse_all(item)
                 self.add_to_queue(data)
                 self.put_item_to_db(data, db_path)
             except ValueError:
                 logging.warning('Error in: %s', item[0])
             finally:
                 self.queue.set(item[0])
 def add_xml_libraries(self, path_to_xml):
     """Adds the found xml libraries to the queue"""
     for file_ in finder(path_to_xml, 'xml'):
         root = ET.parse(file_).getroot()
         if root.attrib['type'] == DBJsonSetting.library:
             self.queue.add(file_, DBJsonSetting.library, [])
Example #4
0
if(funcname == "getsize"):
    imgPath = args[2]
    dist_OP = args[3] # distance between object and observing plane of shadow image
    dist_SO = args[4] # distance between source and object
    
    parser = Parser()
    parser.fit(imgPath)
    parser.getpenumbra()
    parser.getumbra()
    print("radius of umbra: ",parser.ru)
    print("radius of penumbra: ",parser.rp)

    rs, ro = getsizes(dist_OP,dist_SO,parser.ru,parser.rp)

    print("radius of Light Source: "+str(round(rs,2))
    print("radius of Object: "+str(round(ro,2))



elif(funcname == "find"):
    obj = args[2]
    if(len(args) == 4):
        loc = args[3]
    objt = finder()
    objt.fit(obj,refLoc=loc)
    objt.liveplot()
    
else:
    raise Exception("Function not available.")

Example #5
0
 def add_xml_libraries(self, path_to_xml):
     """Adds the found xml libraries to the queue"""
     for file_ in finder(path_to_xml, 'xml'):
         root = ET.parse(file_).getroot()
         if root.attrib['type'] == DBJsonSetting.library:
             self.queue.add(file_, DBJsonSetting.library, [])
 def test2(self):
     self.assertEqual(finder([1, 2, 3, 4, 5, 6, 7], [3, 7, 2, 1, 4, 6]), 5)
 def test1(self):
     self.assertEqual(finder([5, 5, 7, 7], [5, 7, 7]), 5)
 def test3(self):
     self.assertEqual(
         finder([9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 5, 4, 3, 2, 1]), 6)
Example #9
0
sleep(1)

ML_workshop = list()  #워크샵 모드 리스트
ML_local = list()  #로컬 모드 리스트
ML_active = list()  # 활성화된 모드 리스트
MD_num_name = dict()  # 번호 : 이름
MD_name_num = dict()  # 이름 : 번호
ML_sorted = list()  # 배열이 완료된 리스트
ML_error = list()  #배열 안된 리스트

rimexedir = str()  #림월드 exe 파일 위치
local_mod_dir = str()
workshop_mod_dir = str()

#0. 림월드 위치 묻기
rimexedir, local_mod_dir = finder.finder()
print('\n')

#1. 림월드 로컬 모드 검색
Parser.mod_loader(ML_local, MD_name_num, MD_num_name, local_mod_dir)
print('\n')

#2. 림월드 워크샵 모드 탐색
workshop_skip = False
try:
    temp = local_mod_dir.split("/")
    del temp[len(temp) - 3:]
    temp = "\\".join(temp)
    workshop_dir = '{}\\workshop\\content\\294100'.format(temp)
    if os.path.isdir(workshop_dir) == False:
        raise (ValueError)
Example #10
0
	def __init__(self, hostname, target, auto):
		cmd.Cmd.__init__(self)
		self.config = ConfigParser.ConfigParser()
                self.config.read('fw_wrapper.cfg')

		#set up logging
		name = 'fw_wrapper'
		self.logger = fw_logging.getLogger(logging.DEBUG,name,hostname,target)

		self.logger.info('welcome to ' + str(name) + ' please select your tool')
		
		#check to make sure running as root
		if getpass.getuser() != 'root':
			self.logger.critical('not running as root, bailing')
			sys.exit()	
		self.prompt = 'FW>>'
		self.hostname = hostname
		self.target = target
		self.logger.info('hostname: ' + str(self.hostname))
		self.logger.info('target: ' + str(self.target))
		self.logger.debug('calling finder')
		finder.finder(hostname,target)
		self.tool_versions = {}
		try:
			self.tools = self.config.get('main','tools')
		except:
			self.logger.exception('could not read the tools in main section of the config')
			sys.exit()
		
		try:
			self.log_dir = self.config.get('main','log_dir')
		except:
			self.logger.exception('could not read the log_dir in the main section of the config')
			sys.exit()
	
		try:
			self.root_path = self.config.get('main','root_path')
		except:
			self.logger.exception('could not read the root_path in the main section of the config')
			sys.exit()

		try:
			self.script_dir = self.config.get('main','script_dir')
		except:
			self.logger.exception('could not read script_dir in the main section of the config')
			sys.exit()

		try:
			self.fg_dir = self.config.get('main','fg_dir')
		except:
			self.logger.exception('could not read fg_dir in the main section of the config')

		try:
			self.bg_versions = self.config.get('bananaglee','versions').split(',')
		except:
			self.logger.exception('could not get the bananaglee versions')

		self.shelve_file = os.path.join(self.log_dir,'firewall_' + str(hostname) + '.' + str(target) + '.shelve')

		if os.path.isfile(self.shelve_file) == True:
			pass
		else:
			self.logger.error('Could not find your shelve file')
		
		try:
			self.sfile = shelve.open(self.shelve_file)	
		except:
			self.logger.exception('could not open the shelve file: ' + str(self.shelve_file))
			sys.exit()

		self.sfile['hostname'] = self.hostname
		self.sfile['target'] = self.target
		self.sfile['root_path'] = self.root_path
                self.sfile['script_dir'] = self.script_dir
                self.sfile['log_dir'] = self.log_dir
                self.sfile['fg_dir'] = self.fg_dir

		self.sfile['do_tunnel'] = True

		self.sfile['echo'] = self.config.get('main','echo')
		self.sfile['nc'] = self.config.get('main','nc')

		#check fg for files
		for root, subFolders, files in os.walk(self.fg_dir):
			for file in files:
				if '.zip' in file:
					if 'firewall' in file:
						self.logger.info('found ' + str(os.path.join(root,file)) + ' unzipping')
						tools.unzip(self.logger,os.path.join(root,file),root)

                for root, subFolders, files in os.walk(self.fg_dir):
                        for file in files:
				if '.key' in file:
					self.logger.info('found ' + str(os.path.join(root,file)) + ' moving to ' + str(os.path.join(self.root_path,'OPS')))
					shutil.copy(os.path.join(root,file),os.path.join(self.root_path,'OPS'))
				if '.shelve' in file:
					self.logger.info('found ' + str(os.path.join(root,file)) + ' moving to ' + str(self.log_dir))
					shutil.copy(os.path.join(root,file),self.log_dir)
				

                if auto[0] == True:
                        self.sfile['auto'] = True
			#auto has been set to true
                        if auto[1] == True and auto[2] == True:
                                self.logger.error('you specified auto with start and end')
                        elif auto[1] == True:
                                self.logger.info('going into auto mode for the start of the op')
				self.sfile['auto_start'] = True
				if self.sfile['tool'] == 'bananaglee':
					bananaglee_mod = bananaglee.BananaGlee(self.sfile, self.logger)
		                        bananaglee_mod.cmdloop()
	                elif auto[2] == True:
                                self.logger.info('going into auto mode for the end of the op')
				self.sfile['auto_end'] = True
				if self.sfile['tool'] == 'bananaglee':
	                                tunnel_mod = tunnel.Tunnel(self.sfile,self.logger)
        	                        tunnel_mod.cmdloop()
                        else:
                                self.logger.error('you specifed auto but did not tell me if it was the start or end of the op')
		else:
			self.sfile['auto'] = False