示例#1
0
    def do_register_lab_reader(self):
        LAB_FILEROOT = 'main'
        storage = QLStorageSource(config)
        path = self.form_result['path']
        name = self.form_result['path'][3:] # sans DR
        new_reader_path = storage.real_path(LAB_FILEROOT, self.form_result['path'])

        new_reader = Box2(name=name,
                          code=name,
                          src_dir=path,
                          reader_type=Box2.READER_TYPE_WHOLE,
                          active=True,
                          fileroot=LAB_FILEROOT)
        Session.add(new_reader)
        Session.commit()
        session['flash'] = 'Reader %s added.' % name
        session.save()
        return redirect(url(controller='admin', action='register_lab'))
示例#2
0
    def _register_lab_base(self):
        """
        This works in reverse of create().  Instead, require that the user
        create a folder on HyperV, and then only show the new folders that
        have not yet been registered.
        """
        LAB_FILEROOT = 'main'

        file_source = QLStorageSource(config)
        dir_root = file_source.real_path(LAB_FILEROOT,'')
        rel_dirs = [os.path.relpath(path, dir_root) for path in glob.glob('%s/DR*' % dir_root)]

        # for now, assume that a lab reader will be at the top level
        lab_drs = [record[0].split('/')[0] for record in Session.query(Box2.src_dir).all()]
        new_dirs = set(rel_dirs) - set(lab_drs)

        # what should remain are new directories and misnamed directories
        c.reader_field = {'value': '',
                          'options': [(d, d[3:]) for d in new_dirs]}

        return render('/admin/register_lab.html')