How to use region method in ATX

Best Python code snippet using ATX

Fd.py

Source:Fd.py Github

copy

Full Screen

1## @file2# process FD generation3#4# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>5#6# This program and the accompanying materials7# are licensed and made available under the terms and conditions of the BSD License8# which accompanies this distribution. The full text of the license may be found at9# http://opensource.org/licenses/bsd-license.php10#11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.13#1415##16# Import Modules17#18import Region19import Fv20import Common.LongFilePathOs as os21import StringIO22import sys23from struct import *24from GenFdsGlobalVariable import GenFdsGlobalVariable25from CommonDataClass.FdfClass import FDClassObject26from Common import EdkLogger27from Common.BuildToolError import *28from Common.Misc import SaveFileOnChange29from GenFds import GenFds3031## generate FD32#33#34class FD(FDClassObject):35 ## The constructor36 #37 # @param self The object pointer38 #39 def __init__(self):40 FDClassObject.__init__(self)4142 ## GenFd() method43 #44 # Generate FD45 #46 # @retval string Generated FD file name47 #48 def GenFd (self):49 if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict.keys():50 return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd']5152 #53 # Print Information54 #55 GenFdsGlobalVariable.InfLogger("Fd File Name:%s" %self.FdUiName)56 Offset = 0x0057 for item in self.BlockSizeList:58 Offset = Offset + item[0] * item[1]59 if Offset != self.Size:60 EdkLogger.error("GenFds", GENFDS_ERROR, 'FD %s Size not consistent with block array' % self.FdUiName)61 GenFdsGlobalVariable.VerboseLogger('Following Fv will be add to Fd !!!')62 for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict:63 GenFdsGlobalVariable.VerboseLogger(FvObj)6465 GenFdsGlobalVariable.VerboseLogger('################### Gen VTF ####################')66 self.GenVtfFile()6768 TempFdBuffer = StringIO.StringIO('')69 PreviousRegionStart = -170 PreviousRegionSize = 171 72 for RegionObj in self.RegionList :73 if RegionObj.RegionType == 'CAPSULE':74 continue75 if RegionObj.Offset + RegionObj.Size <= PreviousRegionStart:76 pass77 elif RegionObj.Offset <= PreviousRegionStart or (RegionObj.Offset >=PreviousRegionStart and RegionObj.Offset < PreviousRegionStart + PreviousRegionSize):78 pass79 elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSize:80 GenFdsGlobalVariable.InfLogger('Padding region starting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))81 PadRegion = Region.Region()82 PadRegion.Offset = PreviousRegionStart + PreviousRegionSize83 PadRegion.Size = RegionObj.Offset - PadRegion.Offset84 PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)85 PreviousRegionStart = RegionObj.Offset86 PreviousRegionSize = RegionObj.Size87 #88 # Call each region's AddToBuffer function89 #90 if PreviousRegionSize > self.Size:91 pass92 GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')93 RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)94 95 FdBuffer = StringIO.StringIO('')96 PreviousRegionStart = -197 PreviousRegionSize = 198 for RegionObj in self.RegionList :99 if RegionObj.Offset + RegionObj.Size <= PreviousRegionStart:100 EdkLogger.error("GenFds", GENFDS_ERROR,101 'Region offset 0x%X in wrong order with Region starting from 0x%X, size 0x%X\nRegions in FDF must have offsets appear in ascending order.'\102 % (RegionObj.Offset, PreviousRegionStart, PreviousRegionSize))103 elif RegionObj.Offset <= PreviousRegionStart or (RegionObj.Offset >=PreviousRegionStart and RegionObj.Offset < PreviousRegionStart + PreviousRegionSize):104 EdkLogger.error("GenFds", GENFDS_ERROR,105 'Region offset 0x%X overlaps with Region starting from 0x%X, size 0x%X' \106 % (RegionObj.Offset, PreviousRegionStart, PreviousRegionSize))107 elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSize:108 GenFdsGlobalVariable.InfLogger('Padding region starting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))109 PadRegion = Region.Region()110 PadRegion.Offset = PreviousRegionStart + PreviousRegionSize111 PadRegion.Size = RegionObj.Offset - PadRegion.Offset112 PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)113 PreviousRegionStart = RegionObj.Offset114 PreviousRegionSize = RegionObj.Size115 #116 # Verify current region fits within allocated FD section Size117 #118 if PreviousRegionStart + PreviousRegionSize > self.Size:119 EdkLogger.error("GenFds", GENFDS_ERROR,120 'FD %s size too small to fit region with offset 0x%X and size 0x%X'121 % (self.FdUiName, PreviousRegionStart, PreviousRegionSize))122 #123 # Call each region's AddToBuffer function124 #125 GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')126 RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)127 #128 # Create a empty Fd file129 #130 GenFdsGlobalVariable.VerboseLogger ('Create an empty Fd file')131 FdFileName = os.path.join(GenFdsGlobalVariable.FvDir,self.FdUiName + '.fd')132 #133 # Write the buffer contents to Fd file134 #135 GenFdsGlobalVariable.VerboseLogger('Write the buffer contents to Fd file')136 SaveFileOnChange(FdFileName, FdBuffer.getvalue())137 FdBuffer.close();138 GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] = FdFileName139 return FdFileName140141 ## generate VTF142 #143 # @param self The object pointer144 #145 def GenVtfFile (self) :146 #147 # Get this Fd's all Fv name148 #149 FvAddDict ={}150 FvList = []151 for RegionObj in self.RegionList:152 if RegionObj.RegionType == 'FV':153 if len(RegionObj.RegionDataList) == 1:154 RegionData = RegionObj.RegionDataList[0]155 FvList.append(RegionData.upper())156 FvAddDict[RegionData.upper()] = (int(self.BaseAddress,16) + \157 RegionObj.Offset, RegionObj.Size)158 else:159 Offset = RegionObj.Offset160 for RegionData in RegionObj.RegionDataList:161 FvList.append(RegionData.upper())162 FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(RegionData.upper())163 if len(FvObj.BlockSizeList) < 1:164 EdkLogger.error("GenFds", GENFDS_ERROR,165 'FV.%s must point out FVs blocksize and Fv BlockNum' \166 % FvObj.UiFvName)167 else:168 Size = 0169 for blockStatement in FvObj.BlockSizeList:170 Size = Size + blockStatement[0] * blockStatement[1]171 FvAddDict[RegionData.upper()] = (int(self.BaseAddress,16) + \172 Offset, Size)173 Offset = Offset + Size174 #175 # Check whether this Fd need VTF176 #177 Flag = False178 for VtfObj in GenFdsGlobalVariable.FdfParser.Profile.VtfList:179 compLocList = VtfObj.GetFvList()180 if set(compLocList).issubset(FvList):181 Flag = True182 break183 if Flag == True:184 self.vtfRawDict = VtfObj.GenVtf(FvAddDict)185186 ## generate flash map file187 #188 # @param self The object pointer189 #190 def GenFlashMap (self):191 pass192193194195196197198 ...

Full Screen

Full Screen

controller_region.py

Source:controller_region.py Github

copy

Full Screen

...4class ControllerRegion(Controller):5 def check_exist(self, data):6 if not isinstance(data, dict):7 return None8 region = self._parse_region(data=data, region=None)9 if region is None:10 return None11 search = session.query(Region).filter(Region.name == region.name, Region.acronym == region.acronym).first()12 if search is None:13 return False, region14 else:15 return True, search16 def insert(self, data):17 # exist, region = self.check_exist(data=data)18 # if exist:19 # return region #self.update(data=data, object_id=region.port_id)20 # else:21 try:22 region = self._parse_region(data=data, region=None)23 session.add(region)24 session.commit()25 return region26 except Exception as e:27 print(e.__str__())28 session.rollback()29 return None30 # finally:31 # session.close()32 def update(self, data, object_id):33 region = session.query(Region).filter_by(region_id=object_id).first()34 region = self._parse_region(data=data, region=region)35 try:36 session.commit()37 return region38 except Exception as e:39 print(e.__str__())40 session.rollback()41 return None42 # finally:43 # session.close()44 def select(self):45 regions = session.query(Region).all()46 return regions47 def get_by_id(self, region_id):48 region = session.query(Region).filter_by(region_id=region_id).first()49 return region50 def _parse_region(self, data, region=None):51 name, acronym, description = None, None, None52 if 'name' in data:53 name = str(data['name']).strip()54 if 'acronym' in data:55 acronym = str(data['acronym']).strip()56 if 'description' in data:57 description = str(data['description']).strip()58 if region is None:59 region = Region(name=name, acronym=acronym, description=description)60 else:61 region.name = name62 region.acronym = acronym63 region.description = description64 return region

Full Screen

Full Screen

region.py

Source:region.py Github

copy

Full Screen

1#! /usr/bin/env python2# -*- coding: utf-8 -*-3from django.shortcuts import render, HttpResponseRedirect, get_object_or_4044from django.core.urlresolvers import reverse5from django.contrib.auth.decorators import login_required6from branches.models import Region7from branches.forms import RegionForm8from accounts.permission import permission_verify9@login_required()10@permission_verify()11def region_list(request):12 regions = Region.objects.all()13 results = {14 'regions': regions,15 }16 return render(request, 'branches/region_list.html', results)17@login_required18@permission_verify()19def region_del(request):20 region_id = request.GET.get('id', '')21 if region_id:22 Region.objects.filter(id=region_id).delete()23 region_id_all = str(request.POST.get('region_id_all', ''))24 if region_id_all:25 for region_id in region_id_all.split(','):26 Region.objects.filter(id=region_id).delete()27 return HttpResponseRedirect(reverse('region_list'))28@login_required29@permission_verify()30def region_add(request):31 if request.method == 'POST':32 form = RegionForm(request.POST)33 if form.is_valid():34 form.save()35 return HttpResponseRedirect(reverse('region_list'))36 else:37 form = RegionForm()38 results = {39 'form': form,40 'request': request,41 }42 return render(request, 'branches/region_base.html', results)43@login_required44@permission_verify()45def region_edit(request, region_id):46 region_obj = get_object_or_404(Region, pk=region_id)47 if request.method == 'POST':48 form = RegionForm(request.POST, instance=region_obj)49 if form.is_valid():50 form.save()51 return HttpResponseRedirect(reverse('region_list'))52 else:53 form = RegionForm(instance=region_obj)54 results = {55 'form': form,56 'region_id': region_id,57 'request': request,58 }59 return render(request, 'branches/region_base.html', results)60@login_required61@permission_verify()62def branch_detail(request, region_id):63 region = Region.objects.get(id=region_id)64 branches = region.branch_set.all()65 results = {66 'branches': branches,67 }...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful