Пример #1
0
 def __init__(self, print_queue=None,store=None, settings=None, 
              versions=None):
     '''
     Initialize the print_queue and specify a store if one is needed. If not 
     then the class automatically  creates a new instance
     '''
     self.print_queue = print_queue
     if store == None:
         self.store = ExtractStore.ExtractStore()
     else:
         self.store = store
     imp = Importer()
     
     defns = imp.get_package_modules( "AndroidMisc", IMiscSource() )
     if versions != None:
         platform = versions.get_device_version()
         self.selfprint("Platform Version: {}".format(platform))
         self.misc_definitions = []
         for defn in defns:
             title = defn.title.internal_name
             if defn.for_version(platform): 
                 self.selfprint("Adding Module {}".format(title))
                 self.misc_definitions.append(defn)
             else:
                 self.selfprint("No match for {} versions: {}".format(title, 
                                 ','.join([ str(i) for i in defn.version])))
     else:
         self.misc_definitions = imp.get_package_modules( "AndroidMisc", 
                                                           IMiscSource() )
     if self.print_queue != None:
         self.selfprint("Initialized Misc Parser")
     self.dummyRE = type(re.compile("A"))
     self.settings = settings
     return
Пример #2
0
    def _begin_scan(self, location):
        #----------------------------------------------------------------------
        #Initiating device version scanning
        #----------------------------------------------------------------------
        #XXX should remove this and add it in HttpServe when loading case
        self.print_queue.put("** Determining Device/Apps versions **")
        mounts = MountPoints()
        mounts.set_mountpoint(MountPoints.MOUNT_DATA, location)
        versions = AndroidDeviceVersion(self.print_queue, mounts)
        versions.populate_info()
        versions.print_debug()

        #----------------------------------------------------------------------
        #Initiating file system scanning and populating of data
        #----------------------------------------------------------------------
        self.print_queue.put("** Running Application Parser **")
        app_parser = ApplicationParser(self.print_queue,
                                       self.extract_store,
                                       location,
                                       settings=self.settings,
                                       versions=versions)
        #XXX note that this is hard-coded. If for some reason Android app store
        # location changes, this would need to reflect it
        app_parser.scan_directory(os.path.join(location, "data"))

        self.print_queue.put("** Running Configuration Parser **")
        misc_parser = MiscParser(self.print_queue,
                                 self.extract_store,
                                 settings=self.settings,
                                 versions=versions)
        misc_parser.scan_directory(location)
        #----------------------------------------------------------------------
        # Initiating auxiliary modules
        #----------------------------------------------------------------------
        self.print_queue.put("** Running Auxiliary Modules **")

        auxmods = Importer().get_package_modules(
            "AndroidAuxiliary", IAuxiliary(),
            (self.extract_store, self.print_queue))
        auxmods.sort(key=lambda d: d.index)
        for mod in auxmods:
            mod.begin()
        #Finished, sending FIN signal
        self.print_queue.put("FIN")
        return
Пример #3
0
 def __init__(self, outqueue=None, extract_store=None, mountpoint=None, 
              settings=None, versions=None ):
     self.mimguess = MimeGuesser()
     self.outqueue = outqueue
     self.settings = settings
     self.versions = versions
     imp = Importer()
     app_modules = imp.get_package_modules("AndroidApps", IApp())
     for app in app_modules:
         name = app.get_packagename()
         if name in self.appstore:
             self.appstore[name].append(app)
         else:
             self.appstore[name] = [app]
     if extract_store != None:
         self.exstore = extract_store
     else:
         self.exstore = ExtractStore.ExtractStore()
Пример #4
0
 def _begin_scan(self, location):
     #----------------------------------------------------------------------
     #Initiating device version scanning
     #----------------------------------------------------------------------
     #XXX should remove this and add it in HttpServe when loading case
     self.print_queue.put("** Determining Device/Apps versions **")
     mounts = MountPoints()
     mounts.set_mountpoint(MountPoints.MOUNT_DATA, location)
     versions = AndroidDeviceVersion(self.print_queue,mounts)
     versions.populate_info()
     versions.print_debug()
     
     
     #----------------------------------------------------------------------
     #Initiating file system scanning and populating of data
     #----------------------------------------------------------------------
     self.print_queue.put("** Running Application Parser **")
     app_parser = ApplicationParser( self.print_queue, self.extract_store, 
                                     location, settings=self.settings, 
                                     versions=versions )
     #XXX note that this is hard-coded. If for some reason Android app store
     # location changes, this would need to reflect it
     app_parser.scan_directory( os.path.join( location, "data" ) )
     
     self.print_queue.put("** Running Configuration Parser **")
     misc_parser = MiscParser( self.print_queue, self.extract_store, 
                               settings=self.settings, versions=versions )
     misc_parser.scan_directory(location)
     #----------------------------------------------------------------------
     # Initiating auxiliary modules
     #----------------------------------------------------------------------
     self.print_queue.put("** Running Auxiliary Modules **")
     
     auxmods = Importer().get_package_modules( "AndroidAuxiliary", 
                     IAuxiliary(), ( self.extract_store, self.print_queue ) )
     auxmods.sort(key=lambda d: d.index)
     for mod in auxmods:
         mod.begin()
     #Finished, sending FIN signal
     self.print_queue.put("FIN")
     return
Пример #5
0
 def __init__(self,
              outqueue=None,
              extract_store=None,
              mountpoint=None,
              settings=None,
              versions=None):
     self.mimguess = MimeGuesser()
     self.outqueue = outqueue
     self.settings = settings
     self.versions = versions
     imp = Importer()
     app_modules = imp.get_package_modules("AndroidApps", IApp())
     for app in app_modules:
         name = app.get_packagename()
         if name in self.appstore:
             self.appstore[name].append(app)
         else:
             self.appstore[name] = [app]
     if extract_store != None:
         self.exstore = extract_store
     else:
         self.exstore = ExtractStore.ExtractStore()
Пример #6
0
import os
from copy import copy
from mako.lookup import TemplateLookup
from ModuleImporter import Importer
from IWidget import IWidget

PIE_CHART = 1
TIMEGRAPH = 2
TABLE = 3

_WIDGET_PATH = os.path.join("_html", "widgets")

_TEMPL = TemplateLookup(directories=_WIDGET_PATH,
                        output_encoding='utf-8',
                        encoding_errors='ignore')
_MODULES = Importer().get_package_modules_dict("Widgets", IWidget(),
                                               'module_id')
_ID = 1


def _get_id():
    global _ID
    ret = _ID
    _ID += 1
    return ret


def render_widget(widget_id, colsize, data, title):
    global _MODULES, _TEMPL
    if widget_id in _MODULES:
        res = _MODULES[widget_id]._render_widget(_get_id(), _TEMPL, colsize,
                                                 title, data)