当前位置: 首页>>代码示例>>Python>>正文


Python DeviceManager.clear方法代码示例

本文整理汇总了Python中steelscript.appfwk.apps.devices.devicemanager.DeviceManager.clear方法的典型用法代码示例。如果您正苦于以下问题:Python DeviceManager.clear方法的具体用法?Python DeviceManager.clear怎么用?Python DeviceManager.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在steelscript.appfwk.apps.devices.devicemanager.DeviceManager的用法示例。


在下文中一共展示了DeviceManager.clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from steelscript.appfwk.apps.devices.devicemanager import DeviceManager [as 别名]
# 或者: from steelscript.appfwk.apps.devices.devicemanager.DeviceManager import clear [as 别名]
    def post(self, request):

        form = DeviceBatchForm(data=request.POST,
                               files=request.FILES)

        if not form.is_valid():
            return Response({'form': form},
                            template_name='device_batch.html')

        data = form.cleaned_data

        try:
            msg = StringIO()
            management.call_command('device', batch_file=data['batch_file'],
                                    stdout=msg)
            messages.add_message(request._request, messages.INFO,
                                 msg.getvalue())
        except CommandError as e:
            form._errors['batch_file'] = form.error_class([e])

            return Response({'form': form},
                            template_name='device_batch.html')

        DeviceManager.clear()

        return HttpResponseRedirect(reverse('device-list'))
开发者ID:riverbed,项目名称:steelscript-appfwk,代码行数:28,代码来源:views.py

示例2: put

# 需要导入模块: from steelscript.appfwk.apps.devices.devicemanager import DeviceManager [as 别名]
# 或者: from steelscript.appfwk.apps.devices.devicemanager.DeviceManager import clear [as 别名]
    def put(self, request, *args, **kwargs):
        """ Function to save changes to multiple devices once.

        This function is called only when the "Save Changes" button is
        clicked on /devices/ page. However, it only supports enable/disable
        device(s). The url sent out will only include 'enable' field.
        """
        DeviceFormSet = modelformset_factory(Device,
                                             form=DeviceListForm,
                                             extra=0)
        formset = DeviceFormSet(request.DATA)

        if formset.is_valid():
            formset.save()
            DeviceManager.clear()
            messages.success(request._request,
                             'Changes successfully saved')
            if '/devices' not in request.META['HTTP_REFERER']:
                return HttpResponseRedirect(request.META['HTTP_REFERER'])
            else:
                return HttpResponseRedirect(reverse('device-list'))

        else:
            data = {'formset': formset, 'auth': Auth}
            return Response(data, template_name='device_list.html')
开发者ID:riverbed,项目名称:steelscript-appfwk,代码行数:27,代码来源:views.py

示例3: handle

# 需要导入模块: from steelscript.appfwk.apps.devices.devicemanager import DeviceManager [as 别名]
# 或者: from steelscript.appfwk.apps.devices.devicemanager.DeviceManager import clear [as 别名]
    def handle(self, *args, **options):
        self.stdout.write('Reloading report objects ... ')

        management.call_command('clean_pyc', path=settings.PROJECT_ROOT)
        management.call_command('syncdb', interactive=False)

        self.importer = Importer(buf=self.stdout)

        if options['report_id']:
            # single report
            report_id = options['report_id']
            pk = int(report_id)
            report = Report.objects.get(pk=pk)

            management.call_command('clean',
                                    applications=False,
                                    report_id=report_id,
                                    clear_cache=False,
                                    clear_logs=False)

            DeviceManager.clear()
            self.import_module(report.sourcefile)

        elif options['report_name']:
            name = options['report_name']
            try:
                report = Report.objects.get(sourcefile__endswith=name)
                sourcefile = report.sourcefile
                management.call_command('clean',
                                        applications=False,
                                        report_id=report.id,
                                        clear_cache=False,
                                        clear_logs=False)
                self.import_module(sourcefile)
            except ObjectDoesNotExist:
                self.import_module(name)

            DeviceManager.clear()

        elif options['namespace']:
            reports = Report.objects.filter(namespace=options['namespace'])
            self.capture_enabled(reports)

            # clear all data from one namespace (module)
            for report in reports:
                management.call_command('clean',
                                        applications=False,
                                        report_id=report.id,
                                        clear_cache=False,
                                        clear_logs=False)

            # ignore all dirs besides the one we cleared, then import
            root_dir = settings.REPORTS_DIR
            target_dir = options['namespace']
            ignore_list = [os.path.basename(os.path.normpath(x))
                           for x in os.listdir(root_dir) if x != target_dir]
            self.importer.import_directory(
                root_dir, ignore_list=ignore_list)

            self.apply_enabled()

        else:
            self.capture_enabled()

            # clear all data
            management.call_command('clean',
                                    applications=True,
                                    report_id=None,
                                    clear_cache=True,
                                    clear_logs=False)

            # start with fresh device instances
            DeviceManager.clear()

            report_dir = settings.REPORTS_DIR
            self.importer.import_directory(report_dir, report_name=None)

            self.apply_enabled()
开发者ID:carriercomm,项目名称:steelscript-appfwk,代码行数:80,代码来源:reload.py

示例4: test_clear_with_device_id

# 需要导入模块: from steelscript.appfwk.apps.devices.devicemanager import DeviceManager [as 别名]
# 或者: from steelscript.appfwk.apps.devices.devicemanager.DeviceManager import clear [as 别名]
 def test_clear_with_device_id(self):
     DeviceManager.clear(device_id=1)
     self.assertFalse(1 in DeviceManager.devices)
开发者ID:riverbed,项目名称:steelscript-appfwk,代码行数:5,代码来源:test_internal.py

示例5: test_clear

# 需要导入模块: from steelscript.appfwk.apps.devices.devicemanager import DeviceManager [as 别名]
# 或者: from steelscript.appfwk.apps.devices.devicemanager.DeviceManager import clear [as 别名]
 def test_clear(self):
     DeviceManager.clear()
     self.assertEqual(DeviceManager.devices, {})
开发者ID:riverbed,项目名称:steelscript-appfwk,代码行数:5,代码来源:test_internal.py


注:本文中的steelscript.appfwk.apps.devices.devicemanager.DeviceManager.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。