Esempio n. 1
0
    def testLogIndexSearch(self):
        supportDir = os.path.join(self.mobileDir, "support")
        iphoneSupportDir = os.path.join(supportDir, "iphone")
        sys.path.insert(0, supportDir)
        sys.path.insert(0, iphoneSupportDir)

        import tiapp
        from builder import is_indexing_enabled

        testResourcesDir = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "testResources")
        tiappEnableMdfind = tiapp.TiAppXML(
            os.path.join(testResourcesDir, "tiapp_enablemdfind.xml"))
        tiappDisableMdfind = tiapp.TiAppXML(
            os.path.join(testResourcesDir, "tiapp_disablemdfind.xml"))

        simulatorDir = os.path.expanduser(
            '~/Library/Application Support/iPhone Simulator/%s' %
            self.iosVersion)

        nonRootDisabled = "/:\n\tIndexing enabled.\n/Volumes/Dummy:\n\tIndexing disabled."
        rootDisabledUsersEnabled = "/:\n\tIndexing disabled.\n/Users:\n\tIndexing enabled."
        onlyRootDisabled = "/:\n\tIndexing disabled."
        onlyRootEnabled = "/:\n\tIndexing enabled."

        # should be disabled in leopard, regardless of enablemdfind property
        self.assertFalse(
            is_indexing_enabled(tiappEnableMdfind,
                                simulatorDir,
                                platform_release="9.0.0"))

        # enablemdfind = false should disable
        self.assertFalse(is_indexing_enabled(tiappDisableMdfind, simulatorDir))

        # indexing disabled on non-root volume should still be enabled
        self.assertTrue(
            is_indexing_enabled(tiappEnableMdfind,
                                simulatorDir,
                                indexer_status=nonRootDisabled))

        # indexing enabled when / is disabled, but /Users is enabled
        self.assertTrue(
            is_indexing_enabled(tiappEnableMdfind,
                                simulatorDir,
                                indexer_status=rootDisabledUsersEnabled))

        # indexing disabled when / is disabled by itself
        self.assertFalse(
            is_indexing_enabled(tiappEnableMdfind,
                                simulatorDir,
                                indexer_status=onlyRootDisabled))

        # indexing enabled when / is enabled by itself
        self.assertTrue(
            is_indexing_enabled(tiappEnableMdfind,
                                simulatorDir,
                                indexer_status=onlyRootEnabled))
Esempio n. 2
0
def start_server(dir, options):
    xml = tiapp.TiAppXML(os.path.join(dir, "tiapp.xml"))
    app_id = xml.properties["id"]
    app_guid = xml.properties["guid"]

    lock_file = get_lock_file(dir, options)
    if os.path.exists(lock_file):
        print "Fastdev server already running for %s" % app_id
        sys.exit(0)

    resources_dir = os.path.join(dir, 'Resources')
    FastDevHandler.resources_dir = resources_dir
    FastDevHandler.handshake = app_guid

    global server
    server = ThreadingTCPServer(("", int(options.port)), FastDevHandler)
    port = server.server_address[1]
    print "Serving up files for %s at 0.0.0.0:%d from %s" % (app_id, port, dir)

    f = open(lock_file, 'w+')
    f.write(
        simplejson.dumps({
            "ip": "0.0.0.0",
            "port": port,
            "dir": dir,
            "app_id": app_id,
            "app_guid": app_guid
        }))
    f.close()

    try:
        server.serve_forever()
    except KeyboardInterrupt, e:
        print "Terminated"