Esempio n. 1
0
    def handle(self, *args, **options):
        path, build_slug = args

        app_slugs = []
        perfpath = os.path.join(path, '{}-performance.txt'.format(build_slug))
        if os.path.exists(perfpath):
            os.remove(perfpath)

        for name in os.listdir(os.path.join(path, 'src')):
            _JSON = '.json'
            if name.endswith(_JSON):
                app_slugs.append(name[:-len(_JSON)])

        for slug in app_slugs:
            print 'Fetching %s...' % slug
            source_path = os.path.join(path, 'src', '%s.json' % slug)
            with open(source_path) as f:
                j = json.load(f)
                if j['doc_type'] == 'Application':
                    app = Application.wrap(j)
                elif j['doc_type'] == 'RemoteApp':
                    app = RemoteApp.wrap(j)

            app.version = 1
            if not app.domain:
                app.domain = "test"
            build_path = os.path.join(path, build_slug, slug)
            print ' Creating files...'
            if track_perf:
                with record_performance_stats(perfpath, slug):
                    files = app.create_all_files()
            else:
                files = app.create_all_files()

            self.write_files(files, build_path)
Esempio n. 2
0
    def handle(self, *args, **options):
        path, build_slug = args

        app_slugs = []
        perfpath = os.path.join(path, '{}-performance.txt'.format(build_slug))
        if os.path.exists(perfpath):
            os.remove(perfpath)

        for name in os.listdir(os.path.join(path, 'src')):
            _JSON = '.json'
            if name.endswith(_JSON):
                app_slugs.append(name[:-len(_JSON)])

        for slug in app_slugs:
            print 'Fetching %s...' % slug
            source_path = os.path.join(path, 'src', '%s.json' % slug)
            with open(source_path) as f:
                j = json.load(f)
                if j['doc_type'] == 'Application':
                    app = Application.wrap(j)
                elif j['doc_type'] == 'RemoteApp':
                    app = RemoteApp.wrap(j)

            app.version = 1
            if not app.domain:
                app.domain = "test"
            build_path = os.path.join(path, build_slug, slug)
            print ' Creating files...'
            if options.get('track_perf'):
                with record_performance_stats(perfpath, slug):
                    files = app.create_all_files()
            else:
                files = app.create_all_files()

            self.write_files(files, build_path)
Esempio n. 3
0
    def setUpClass(cls):
        cls.project = Domain(name=cls.domain)
        cls.project.save()
        cls.first_saved_version = 2
        cls.apps = [
            # .wrap adds lots of stuff in, but is hard to call directly
            # this workaround seems to work
            Application.wrap(Application(domain=cls.domain, name="foo", version=1, modules=[Module()]).to_json()),
            RemoteApp.wrap(RemoteApp(domain=cls.domain, version=1, name="bar").to_json()),
        ]
        for app in cls.apps:
            app.save()

        cls.decoy_apps = [
            # this one is a build
            Application(
                domain=cls.domain, copy_of=cls.apps[0].get_id, version=cls.first_saved_version, has_submissions=True
            ),
            # this one is another build
            Application(domain=cls.domain, copy_of=cls.apps[0].get_id, version=12),
            # this one is another app
            Application(domain=cls.domain, copy_of="1234", version=12),
            # this one is in the wrong domain
            Application(domain="decoy-domain", version=5),
        ]
        for app in cls.decoy_apps:
            app.save()
Esempio n. 4
0
    def setUpClass(cls):
        super(DBAccessorsTest, cls).setUpClass()
        cls.project = Domain(name=cls.domain)
        cls.project.save()
        cls.first_saved_version = 2
        cls.apps = [
            # .wrap adds lots of stuff in, but is hard to call directly
            # this workaround seems to work
            Application.wrap(Application(domain=cls.domain, name='foo', version=1, modules=[Module()]).to_json()),
            RemoteApp.wrap(RemoteApp(domain=cls.domain, version=1, name='bar').to_json()),
        ]
        for app in cls.apps:
            app.save()

        cls.decoy_apps = [
            # this one is a build
            Application(
                domain=cls.domain,
                copy_of=cls.apps[0].get_id,
                version=cls.first_saved_version,
                has_submissions=True,
            ),
            # this one is another build
            Application(domain=cls.domain, copy_of=cls.apps[0].get_id, version=12),

            # this one is another app
            Application(domain=cls.domain, copy_of='1234', version=12),
            # this one is in the wrong domain
            Application(domain='decoy-domain', version=5)
        ]
        for app in cls.decoy_apps:
            app.save()
    def setUpClass(cls):
        cls.project = Domain(name=cls.domain)
        cls.project.save()

        cls.apps = [
            # .wrap adds lots of stuff in, but is hard to call directly
            # this workaround seems to work
            Application.wrap(Application(domain=cls.domain, name="foo", version=1, modules=[Module()]).to_json()),
            RemoteApp.wrap(RemoteApp(domain=cls.domain, version=1, name="bar").to_json()),
        ]
        for app in cls.apps:
            app.save()
Esempio n. 6
0
    def setUpClass(cls):
        cls.project = Domain(name=cls.domain)
        cls.project.save()

        cls.apps = [
            # .wrap adds lots of stuff in, but is hard to call directly
            # this workaround seems to work
            Application.wrap(
                Application(domain=cls.domain,
                            name='foo',
                            version=1,
                            modules=[Module()]).to_json()),
            RemoteApp.wrap(
                RemoteApp(domain=cls.domain, version=1, name='bar').to_json()),
        ]
        for app in cls.apps:
            app.save()
Esempio n. 7
0
    def handle(self, *args, **options):
        path, build_slug = args

        app_slugs = []
        for name in os.listdir(os.path.join(path, 'src')):
            _JSON = '.json'
            if name.endswith(_JSON):
                app_slugs.append(name[:-len(_JSON)])

        for slug in app_slugs:
            print 'Fetching %s...' % slug
            source_path = os.path.join(path, 'src', '%s.json' % slug)
            with open(source_path) as f:
                j = json.load(f)
                if j['doc_type'] == 'Application':
                    app = Application.wrap(j)
                elif j['doc_type'] == 'RemoteApp':
                    app = RemoteApp.wrap(j)

            app.version = 1
            build_path = os.path.join(path, build_slug, slug)
            print ' Creating files...'
            self.create_files(app, build_path)
Esempio n. 8
0
    def setUpClass(cls):
        super(DBAccessorsTest, cls).setUpClass()
        cls.project = Domain.get_or_create_with_name(cls.domain, is_active=True)
        cls.first_saved_version = 2

        cls.normal_app = Application.wrap(
            Application(domain=cls.domain, name='foo', version=1, modules=[Module()]).to_json()
        )
        cls.normal_app.save()

        cls.remote_app = RemoteApp.wrap(RemoteApp(domain=cls.domain, version=1, name='bar').to_json())
        cls.remote_app.save()

        cls.linked_app = LinkedApplication.wrap(
            LinkedApplication(domain=cls.domain, version=1, name='linked-app', upstream_app_id='abc123').to_json()
        )
        cls.linked_app.save()

        cls.decoy_apps = [
            # this one is a build
            Application(
                domain=cls.domain,
                copy_of=cls.normal_app.get_id,
                version=cls.first_saved_version,
                has_submissions=True,
            ),
            # this one is another build
            Application(domain=cls.domain, copy_of=cls.normal_app.get_id, version=12),

            # this one is another app
            Application(domain=cls.domain, copy_of='1234', version=12),
            # this one is in the wrong domain
            Application(domain='decoy-domain', version=5)
        ]
        for app in cls.decoy_apps:
            app.save()