Пример #1
0
 def reload_scripts(self, subcall=None):
     """
     Return list with single loaded file
     """
     res = []
     if subcall:
         subcall((0, 1))
     try:
         script = Script()
         script.load_file(self.path)
         res = [script]
     except ScriptParseException:
         pass
     if subcall:
         subcall((1, 1))
     return res
Пример #2
0
 def reload_scripts(self, subcall = None):
     """
     Return list with single loaded file
     """
     res = []
     if subcall:
         subcall((0, 1))
     try:
         script = Script()
         script.load_file(self.path)
         res = [script]
     except ScriptParseException:
         pass
     if subcall:
         subcall((1,1))
     return res
Пример #3
0
 def reload_scripts(self, subcall=None):
     """
     Return list with single downloaded and installed file
     """
     script = None
     if subcall: subcall((0, 1))
     data = self.config.download(self.path)
     if not data:
         return []
     name = urlparse(self.path)[2].split('/')[-1]
     installed_path = self.config.install_script(name, data)
     if installed_path:
         script = Script()
         script.load_file(installed_path)
         script.url = self.path
     if subcall: subcall((1, 1))
     if not script:
         return []
     return [script]
Пример #4
0
 def reload_scripts(self, subcall=None):
     """
     Return list of parsed script files from directory
     """
     res = []
     filelist = [x for x in get_file_list(self.path) if x.endswith('.nse')]
     for i, name in enumerate(filelist):
         if subcall:
             subcall((i, len(filelist)))
         fullname = os.path.join(self.path, name)
         try:
             script = Script()
             script.load_file(fullname)
             res.append(script)
         except ScriptParseException:
             pass
     if subcall:
         subcall((len(filelist), len(filelist)))
     return res
Пример #5
0
 def reload_scripts(self, subcall = None):
     """
     Return list with single downloaded and installed file
     """
     script = None
     if subcall: subcall((0, 1))
     data = self.config.download(self.path)
     if not data:
         return []
     name = urlparse(self.path)[2].split('/')[-1]
     installed_path = self.config.install_script(name, data)
     if installed_path:
         script = Script()
         script.load_file(installed_path)
         script.url = self.path
     if subcall: subcall((1, 1))
     if not script:
         return []
     return [script]
Пример #6
0
 def reload_scripts(self, subcall = None):
     """
     Return list of parsed script files from directory
     """
     res = []
     filelist = [x for x in get_file_list(self.path) if x.endswith('.nse')]
     for i, name in enumerate(filelist):
         if subcall:
             subcall((i, len(filelist)))
         fullname = os.path.join(self.path, name)
         try:
             script = Script()
             script.load_file(fullname)
             res.append(script)
         except ScriptParseException:
             pass
     if subcall:
         subcall((len(filelist), len(filelist)))
     return res        
Пример #7
0
 def load_from_text(self, data):
     """
     Fill base from string data, contains scripts descriptions
     """
     self.reset()
     d = {}
     cur = None
     script_list = []
     for i, line in enumerate(data.splitlines()):
         line = line.strip()
         if not line:
             if d:
                 if not d.has_key('name'):
                     print "Script before line %d have no 'name' parameter" % i
                 else:
                     script = Script()
                     script.load(d)
                     script_list.append(script)
                 d = {}
                 cur = None
             continue
         sep = line.find(':')
         if sep != -1 and line[sep - 1] == '\\':
             sep = -1
         line = line.replace('\\:', ':')
         if cur is None and sep == -1:
             print "Unknown attribute at line %d" % i
             continue
         if sep != -1:
             cur = line[:sep].strip().lower()
             line = line[sep+1:].strip()
             if line == '.': line = ''
             d[cur] = line
         else:
             if line == '.': line = ''
             d[cur] = d[cur] + '\n' + line
     self.from_list(script_list)
 def load_from_text(self, data):
     """
     Fill base from string data, contains scripts descriptions
     """
     self.reset()
     d = {}
     cur = None
     script_list = []
     for i, line in enumerate(data.splitlines()):
         line = line.strip()
         if not line:
             if d:
                 if not d.has_key('name'):
                     print "Script before line %d have no 'name' parameter" % i
                 else:
                     script = Script()
                     script.load(d)
                     script_list.append(script)
                 d = {}
                 cur = None
             continue
         sep = line.find(':')
         if sep != -1 and line[sep - 1] == '\\':
             sep = -1
         line = line.replace('\\:', ':')
         if cur is None and sep == -1:
             print "Unknown attribute at line %d" % i
             continue
         if sep != -1:
             cur = line[:sep].strip().lower()
             line = line[sep + 1:].strip()
             if line == '.': line = ''
             d[cur] = line
         else:
             if line == '.': line = ''
             d[cur] = d[cur] + '\n' + line
     self.from_list(script_list)