How to use kw method in refurb

Best Python code snippet using refurb_python

utils.py

Source:utils.py Github

copy

Full Screen

1# vim: tabstop=4 shiftwidth=4 softtabstop=42# Copyright 2013 Hewlett-Packard Development Company, L.P.3# All Rights Reserved.4#5# Licensed under the Apache License, Version 2.0 (the "License"); you may6# not use this file except in compliance with the License. You may obtain7# a copy of the License at8#9# http://www.apache.org/licenses/LICENSE-2.010#11# Unless required by applicable law or agreed to in writing, software12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the14# License for the specific language governing permissions and limitations15# under the License.16#17# Copyright (c) 2013-2019 Wind River Systems, Inc.18#19"""Sysinv test utilities."""20import uuid21from oslo_serialization import jsonutils as json22from oslo_utils import uuidutils23from sysinv.common import constants24from sysinv.db import api as db_api25fake_info = {"foo": "bar"}26ipmi_info = json.dumps(27 {28 'ipmi': {29 "address": "1.2.3.4",30 "username": "admin",31 "password": "fake",32 }33 })34ssh_info = json.dumps(35 {36 'ssh': {37 "address": "1.2.3.4",38 "username": "admin",39 "password": "fake",40 "port": 22,41 "virt_type": "vbox",42 "key_filename": "/not/real/file",43 }44 })45pxe_info = json.dumps(46 {47 'pxe': {48 "instance_name": "fake_instance_name",49 "image_source": "glance://image_uuid",50 "deploy_kernel": "glance://deploy_kernel_uuid",51 "deploy_ramdisk": "glance://deploy_ramdisk_uuid",52 "root_gb": 100,53 }54 })55pxe_ssh_info = json.dumps(56 dict(json.loads(pxe_info), **json.loads(ssh_info)))57pxe_ipmi_info = json.dumps(58 dict(json.loads(pxe_info), **json.loads(ipmi_info)))59properties = {60 "cpu_arch": "x86_64",61 "cpu_num": "8",62 "storage": "1024",63 "memory": "4096",64 }65int_uninitialized = 99966SW_VERSION = '0.0'67SW_VERSION_NEW = '1.0'68def get_test_node(**kw):69 node = {70 'id': kw.get('id'),71 'numa_node': kw.get('numa_node', 0),72 'capabilities': kw.get('capabilities', {}),73 'forihostid': kw.get('forihostid', 1)74 }75 return node76def create_test_node(**kw):77 """Create test inode entry in DB and return inode DB object.78 Function to be used to create test inode objects in the database.79 :param kw: kwargs with overriding values for host's attributes.80 :returns: Test inode DB object.81 """82 node = get_test_node(**kw)83 # Let DB generate ID if it isn't specified explicitly84 if 'id' not in kw:85 del node['id']86 dbapi = db_api.get_instance()87 return dbapi.inode_create(node['forihostid'], node)88def post_get_test_ihost(**kw):89 inv = get_test_ihost(**kw)90 del inv['bm_mac']91 del inv['peer_id']92 del inv['action_state']93 del inv['recordtype']94 del inv['uuid']95 return inv96def get_test_ihost(**kw):97 inv = {98 'id': kw.get('id', 123),99 'forisystemid': kw.get('forisystemid', None),100 'peer_id': kw.get('peer_id', None),101 'recordtype': kw.get('recordtype', "standard"),102 'uuid': kw.get('uuid'),103 'hostname': kw.get('hostname', 'sysinvhostname'),104 'invprovision': kw.get('invprovision', 'unprovisioned'),105 'mgmt_mac': kw.get('mgmt_mac',106 '01:34:67:9A:CD:FE'),107 'mgmt_ip': kw.get('mgmt_ip',108 '192.168.24.11'),109 'personality': kw.get('personality', 'controller'),110 'administrative': kw.get('administrative', 'locked'),111 'operational': kw.get('operational', 'disabled'),112 'availability': kw.get('availability', 'offduty'),113 'serialid': kw.get('serialid', 'sysinv123456'),114 'bm_ip': kw.get('bm_ip', "128.224.150.193"),115 'bm_mac': kw.get('bm_mac', "a4:5d:36:fc:a5:6c"),116 'bm_type': kw.get('bm_type', constants.HOST_BM_TYPE_DEPROVISIONED),117 'bm_username': kw.get('bm_username', "ihostbmusername"),118 'action': kw.get('action', "none"),119 'task': kw.get('task', None),120 'capabilities': kw.get('capabilities', {}),121 'subfunctions': kw.get('subfunctions', "ihostsubfunctions"),122 'subfunction_oper': kw.get('subfunction_oper', "disabled"),123 'subfunction_avail': kw.get('subfunction_avail', "not-installed"),124 'reserved': kw.get('reserved', None),125 'ihost_action': kw.get('ihost_action', None),126 'action_state': kw.get('action_state', constants.HAS_REINSTALLED),127 'mtce_info': kw.get('mtce_info', '0'),128 'vim_progress_status': kw.get('vim_progress_status', "vimprogressstatus"),129 'uptime': kw.get('uptime', 0),130 'config_status': kw.get('config_status', "configstatus"),131 'config_applied': kw.get('config_applied', "configapplied"),132 'config_target': kw.get('config_target', "configtarget"),133 'location': kw.get('location', {}),134 'boot_device': kw.get('boot_device', 'sda'),135 'rootfs_device': kw.get('rootfs_device', 'sda'),136 'install_output': kw.get('install_output', 'text'),137 'console': kw.get('console', 'ttyS0,115200'),138 'tboot': kw.get('tboot', ''),139 'ttys_dcd': kw.get('ttys_dcd', None),140 'updated_at': None,141 'created_at': None,142 'install_state': kw.get('install_state', None),143 'install_state_info': kw.get('install_state_info', None),144 'iscsi_initiator_name': kw.get('iscsi_initiator_name', None),145 'inv_state': kw.get('inv_state', 'inventoried'),146 'clock_synchronization': kw.get('clock_synchronization', constants.NTP),147 }148 return inv149def create_test_ihost(**kw):150 """Create test host entry in DB and return Host DB object.151 Function to be used to create test Host objects in the database.152 :param kw: kwargs with overriding values for host's attributes.153 :returns: Test Host DB object.154 """155 host = get_test_ihost(**kw)156 # Let DB generate ID if it isn't specified explicitly157 if 'id' not in kw:158 del host['id']159 dbapi = db_api.get_instance()160 return dbapi.ihost_create(host)161def get_test_isystem(**kw):162 inv = {163 'id': kw.get('id', 321),164 'name': kw.get('hostname', 'sysinvisystemname'),165 'description': kw.get('description', 'isystemdescription'),166 'capabilities': kw.get('capabilities',167 {"cinder_backend":168 constants.CINDER_BACKEND_LVM,169 "vswitch_type":170 constants.VSWITCH_TYPE_OVS_DPDK,171 "region_config": False,172 "sdn_enabled": True,173 "shared_services": "[]"}),174 'contact': kw.get('contact', 'isystemcontact'),175 'system_type': kw.get('system_type', constants.TIS_STD_BUILD),176 'system_mode': kw.get('system_mode', constants.SYSTEM_MODE_DUPLEX),177 'region_name': kw.get('region_name', constants.REGION_ONE_NAME),178 'location': kw.get('location', 'isystemlocation'),179 'services': kw.get('services', 72),180 'software_version': kw.get('software_version', SW_VERSION)181 }182 return inv183def create_test_isystem(**kw):184 """Create test system entry in DB and return System DB object.185 Function to be used to create test System objects in the database.186 :param kw: kwargs with overriding values for system's attributes.187 :returns: Test System DB object.188 """189 system = get_test_isystem(**kw)190 # Let DB generate ID if it isn't specified explicitly191 if 'id' not in kw:192 del system['id']193 dbapi = db_api.get_instance()194 return dbapi.isystem_create(system)195def get_test_load(**kw):196 load = {197 "software_version": kw.get("software_version", SW_VERSION),198 "compatible_version": kw.get("compatible_version", "N/A"),199 "required_patches": "N/A",200 "state": kw.get("state", constants.ACTIVE_LOAD_STATE),201 }202 return load203def create_test_load(**kw):204 load = get_test_load(**kw)205 dbapi = db_api.get_instance()206 return dbapi.load_create(load)207def get_test_upgrade(**kw):208 upgrade = {'from_load': kw.get('from_load', 1),209 'to_load': kw.get('to_load', 2),210 'state': kw.get('state', constants.UPGRADE_STARTING)}211 return upgrade212def create_test_upgrade(**kw):213 upgrade = get_test_upgrade(**kw)214 dbapi = db_api.get_instance()215 return dbapi.software_upgrade_create(upgrade)216def post_get_test_kube_upgrade(**kw):217 upgrade = get_test_kube_upgrade(**kw)218 del upgrade['id']219 del upgrade['uuid']220 del upgrade['from_version']221 del upgrade['state']222 del upgrade['reserved_1']223 del upgrade['reserved_2']224 del upgrade['reserved_3']225 del upgrade['reserved_4']226 return upgrade227def get_test_kube_upgrade(**kw):228 upgrade = {229 'id': 1,230 'uuid': kw.get('uuid', uuidutils.generate_uuid()),231 "from_version": kw.get('from_version', 'v1.42.1'),232 "to_version": kw.get('to_version', 'v1.42.2'),233 "state": kw.get('state', 'upgrade-started'),234 "reserved_1": "res1",235 "reserved_2": "res2",236 "reserved_3": "res3",237 "reserved_4": "res4",238 }239 return upgrade240def get_test_kube_host_upgrade():241 upgrade = {242 'id': 1,243 'uuid': uuidutils.generate_uuid(),244 "target_version": 'v1.42.1',245 "status": "tbd",246 "reserved_1": "",247 "reserved_2": "",248 "reserved_3": "",249 "reserved_4": "",250 "host_id": 1,251 }252 return upgrade253def create_test_kube_upgrade(**kw):254 upgrade = get_test_kube_upgrade(**kw)255 # Let DB generate ID and uuid256 if 'id' in upgrade:257 del upgrade['id']258 if 'uuid' in upgrade:259 del upgrade['uuid']260 dbapi = db_api.get_instance()261 return dbapi.kube_upgrade_create(upgrade)262def create_test_kube_host_upgrade():263 upgrade = get_test_kube_host_upgrade()264 # Let DB generate ID, uuid and host_id265 if 'id' in upgrade:266 del upgrade['id']267 if 'uuid' in upgrade:268 del upgrade['uuid']269 if 'host_id' in upgrade:270 del upgrade['host_id']271 dbapi = db_api.get_instance()272 hostid = 1273 return dbapi.kube_host_upgrade_create(hostid, upgrade)274# Create test user object275def get_test_user(**kw):276 user = {277 'id': kw.get('id'),278 'uuid': kw.get('uuid'),279 'forisystemid': kw.get('forisystemid', None)280 }281 return user282def create_test_user(**kw):283 user = get_test_user(**kw)284 # Let DB generate ID if it isn't specified explicitly285 if 'id' not in kw:286 del user['id']287 dbapi = db_api.get_instance()288 return dbapi.iuser_create(user)289# Create test helm override object290def get_test_helm_overrides(**kw):291 helm_overrides = {292 'id': kw.get('id'),293 'name': kw.get('name'),294 'namespace': kw.get('namespace'),295 'user_overrides': kw.get('user_overrides', None),296 'system_overrides': kw.get('system_overrides', None),297 'app_id': kw.get('app_id', None)298 }299 return helm_overrides300def create_test_helm_overrides(**kw):301 helm_overrides = get_test_helm_overrides(**kw)302 # Let DB generate ID if it isn't specified explicitly303 if 'id' not in kw:304 del helm_overrides['id']305 dbapi = db_api.get_instance()306 return dbapi.helm_override_create(helm_overrides)307# Create test ntp object308def get_test_ntp(**kw):309 ntp = {310 'id': kw.get('id'),311 'uuid': kw.get('uuid'),312 'ntpservers': kw.get('ntpservers'),313 'forisystemid': kw.get('forisystemid', None),314 'isystem_uuid': kw.get('isystem_uuid', None)315 }316 return ntp317def create_test_ntp(**kw):318 ntp = get_test_ntp(**kw)319 # Let DB generate ID if it isn't specified explicitly320 if 'id' not in kw:321 del ntp['id']322 dbapi = db_api.get_instance()323 return dbapi.intp_create(ntp)324def post_get_test_ntp(**kw):325 ntp = get_test_ntp(**kw)326 # When invoking a POST the following fields should not be populated:327 del ntp['uuid']328 del ntp['id']329 return ntp330# Create test ptp object331def get_test_ptp(**kw):332 ptp = {333 'id': kw.get('id'),334 'uuid': kw.get('uuid'),335 'enabled': kw.get('enabled'),336 'system_id': kw.get('system_id', None),337 'mode': kw.get('mode'),338 'transport': kw.get('transport'),339 'mechanism': kw.get('mechanism')340 }341 return ptp342def create_test_ptp(**kw):343 ptp = get_test_ptp(**kw)344 # Let DB generate ID if it isn't specified explicitly345 if 'id' not in kw:346 del ptp['id']347 dbapi = db_api.get_instance()348 return dbapi.ptp_create(ptp)349# Create test dns object350def get_test_dns(**kw):351 dns = {352 'id': kw.get('id'),353 'uuid': kw.get('uuid'),354 'nameservers': kw.get('nameservers'),355 'forisystemid': kw.get('forisystemid', None)356 }357 return dns358def create_test_dns(**kw):359 dns = get_test_dns(**kw)360 # Let DB generate ID if it isn't specified explicitly361 if 'id' not in kw:362 del dns['id']363 dbapi = db_api.get_instance()364 return dbapi.idns_create(dns)365def post_get_test_dns(**kw):366 dns = get_test_dns(**kw)367 # When invoking a POST the following fields should not be populated:368 del dns['uuid']369 del dns['id']370 return dns371# Create test drbd object372def get_test_drbd(**kw):373 drbd = {374 'id': kw.get('id'),375 'uuid': kw.get('uuid'),376 'forisystemid': kw.get('forisystemid', None),377 'link_util': constants.DRBD_LINK_UTIL_DEFAULT,378 'num_parallel': constants.DRBD_NUM_PARALLEL_DEFAULT,379 'rtt_ms': constants.DRBD_RTT_MS_DEFAULT,380 }381 return drbd382def create_test_drbd(**kw):383 drbd = get_test_drbd(**kw)384 # Let DB generate ID if it isn't specified explicitly385 if 'id' not in kw:386 del drbd['id']387 dbapi = db_api.get_instance()388 return dbapi.drbdconfig_create(drbd)389# Create test remotelogging object390def get_test_remotelogging(**kw):391 remotelogging = {392 'id': kw.get('id'),393 'uuid': kw.get('uuid'),394 'enabled': kw.get('enabled'),395 'system_id': kw.get('system_id', None)396 }397 return remotelogging398def create_test_remotelogging(**kw):399 dns = get_test_remotelogging(**kw)400 # Let DB generate ID if it isn't specified explicitly401 if 'id' not in kw:402 del dns['id']403 dbapi = db_api.get_instance()404 return dbapi.remotelogging_create(dns)405def get_test_address_pool(**kw):406 inv = {407 'id': kw.get('id'),408 'network': kw.get('network'),409 'name': kw.get('name'),410 'family': kw.get('family', 4),411 'ranges': kw.get('ranges'),412 'prefix': kw.get('prefix'),413 'order': kw.get('order', 'random'),414 'uuid': kw.get('uuid')415 }416 return inv417def create_test_address_pool(**kw):418 """Create test address pool entry in DB and return AddressPool DB object.419 Function to be used to create test Address pool objects in the database.420 :param kw: kwargs with overriding values for address pool's attributes.421 :returns: Test Address pool DB object.422 """423 address_pool = get_test_address_pool(**kw)424 # Let DB generate ID if it isn't specified explicitly425 if 'id' not in kw:426 del address_pool['id']427 dbapi = db_api.get_instance()428 return dbapi.address_pool_create(address_pool)429def get_test_address(**kw):430 inv = {431 'id': kw.get('id'),432 'uuid': kw.get('uuid'),433 'family': kw.get('family'),434 'address': kw.get('address'),435 'prefix': kw.get('prefix'),436 'enable_dad': kw.get('enable_dad', False),437 'name': kw.get('name', None),438 'interface_id': kw.get('interface_id', None),439 'address_pool_id': kw.get('address_pool_id', None),440 }441 return inv442def create_test_address(**kw):443 """Create test address entry in DB and return Address DB object.444 Function to be used to create test Address objects in the database.445 :param kw: kwargs with overriding values for addresses' attributes.446 :returns: Test Address DB object.447 """448 address = get_test_address(**kw)449 # Let DB generate ID if it isn't specified explicitly450 if 'id' not in kw:451 del address['id']452 dbapi = db_api.get_instance()453 return dbapi.address_create(address)454def get_test_route(**kw):455 inv = {456 'id': kw.get('id'),457 'uuid': kw.get('uuid'),458 'family': kw.get('family'),459 'network': kw.get('network'),460 'prefix': kw.get('prefix'),461 'gateway': kw.get('gateway'),462 'metric': kw.get('metric', 1),463 'interface_id': kw.get('interface_id', None),464 }465 return inv466def create_test_route(**kw):467 """Create test route entry in DB and return Route DB object.468 Function to be used to create test Route objects in the database.469 :param kw: kwargs with overriding values for route's attributes.470 :returns: Test Route DB object.471 """472 route = get_test_route(**kw)473 # Let DB generate ID if it isn't specified explicitly474 if 'id' not in kw:475 del route['id']476 dbapi = db_api.get_instance()477 interface_id = route.pop('interface_id')478 return dbapi.route_create(interface_id, route)479def create_test_network(**kw):480 """Create test network entry in DB and return Network DB object.481 Function to be used to create test Network objects in the database.482 :param kw: kwargs with overriding values for network's attributes.483 :returns: Test Network DB object.484 """485 network = get_test_network(**kw)486 # Let DB generate ID if it isn't specified explicitly487 if 'id' not in kw:488 del network['id']489 dbapi = db_api.get_instance()490 return dbapi.network_create(network)491def get_test_network(**kw):492 inv = {493 'id': kw.get('id'),494 'uuid': kw.get('uuid'),495 'type': kw.get('type'),496 'dynamic': kw.get('dynamic', True),497 'address_pool_id': kw.get('address_pool_id', None)498 }499 return inv500def get_test_icpu(**kw):501 inv = {502 'id': kw.get('id'),503 'uuid': kw.get('uuid'),504 'cpu': kw.get('cpu', int_uninitialized),505 'forinodeid': kw.get('forinodeid', int_uninitialized),506 'core': kw.get('core', int_uninitialized),507 'thread': kw.get('thread', 0),508 # 'coProcessors': kw.get('coProcessors', {}),509 'cpu_family': kw.get('cpu_family', 6),510 'cpu_model': kw.get('cpu_model', 'Intel(R) Core(TM)'),511 'allocated_function': kw.get('allocated_function', 'Platform'),512 'forihostid': kw.get('forihostid', None), # 321 ?513 'updated_at': None,514 'created_at': None,515 }516 return inv517def get_test_imemory(**kw):518 inv = {519 'id': kw.get('id'),520 'uuid': kw.get('uuid'),521 'memtotal_mib': kw.get('memtotal_mib', 2528),522 'memavail_mib': kw.get('memavail_mib', 2528),523 'platform_reserved_mib': kw.get('platform_reserved_mib', 1200),524 'node_memtotal_mib': kw.get('node_memtotal_mib', 7753),525 'hugepages_configured': kw.get('hugepages_configured', False),526 'vswitch_hugepages_size_mib': kw.get('vswitch_hugepages_size_mib', 2),527 'vswitch_hugepages_reqd': kw.get('vswitch_hugepages_reqd'),528 'vswitch_hugepages_nr': kw.get('vswitch_hugepages_nr', 256),529 'vswitch_hugepages_avail': kw.get('vswitch_hugepages_avail', 0),530 'vm_hugepages_nr_2M_pending': kw.get('vm_hugepages_nr_2M_pending'),531 'vm_hugepages_nr_1G_pending': kw.get('vm_hugepages_nr_1G_pending'),532 'vm_hugepages_nr_2M': kw.get('vm_hugepages_nr_2M', 1008),533 'vm_hugepages_avail_2M': kw.get('vm_hugepages_avail_2M', 1264),534 'vm_hugepages_nr_1G': kw.get('vm_hugepages_nr_1G', 0),535 'vm_hugepages_avail_1G': kw.get('vm_hugepages_avail_1G'),536 'vm_hugepages_nr_4K': kw.get('vm_hugepages_nr_4K', 131072),537 'vm_hugepages_use_1G': kw.get('vm_hugepages_use_1G', False),538 'vm_hugepages_possible_2M': kw.get('vm_hugepages_possible_2M', 1264),539 'vm_hugepages_possible_1G': kw.get('vm_hugepages_possible_1G', 1),540 'capabilities': kw.get('capabilities', None),541 'forinodeid': kw.get('forinodeid', None),542 'forihostid': kw.get('forihostid', None),543 'updated_at': None,544 'created_at': None,545 }546 return inv547def get_test_idisk(**kw):548 inv = {549 'id': kw.get('id'),550 'uuid': kw.get('uuid'),551 'device_node': kw.get('device_node'),552 'device_path': kw.get('device_path',553 '/dev/disk/by-path/pci-0000:00:0d.0-ata-1.0'),554 'device_num': kw.get('device_num', 2048),555 'device_type': kw.get('device_type'),556 'rpm': kw.get('rpm', 'Undetermined'),557 'serial_id': kw.get('serial_id', 'VBf34cf425-ff9d1c77'),558 'forihostid': kw.get('forihostid', 2),559 'foristorid': kw.get('foristorid', 2),560 'foripvid': kw.get('foripvid', 2),561 'available_mib': kw.get('available_mib', 100),562 'updated_at': None,563 'created_at': None,564 }565 return inv566def create_test_idisk(**kw):567 """Create test idisk entry in DB and return idisk DB object.568 Function to be used to create test idisk objects in the database.569 :param kw: kwargs with overriding values for idisk's attributes.570 :returns: Test idisk DB object.571 """572 idisk = get_test_idisk(**kw)573 # Let DB generate ID if it isn't specified explicitly574 if 'id' not in kw:575 del idisk['id']576 if 'foripvid' not in kw:577 del idisk['foripvid']578 if 'foristorid' not in kw:579 del idisk['foristorid']580 dbapi = db_api.get_instance()581 return dbapi.idisk_create(idisk['forihostid'], idisk)582def get_test_stor(**kw):583 stor = {584 'id': kw.get('id', 2),585 'function': kw.get('function'),586 'idisk_uuid': kw.get('idisk_uuid', 2),587 'forihostid': kw.get('forihostid', 2),588 'forilvgid': kw.get('forilvgid', 2),589 }590 return stor591def get_test_mon(**kw):592 mon = {593 'id': kw.get('id', 2),594 'uuid': kw.get('uuid'),595 'device_path': kw.get('device_path', ''),596 'ceph_mon_gib': kw.get('ceph_mon_gib', 20),597 'state': kw.get('state', 'configured'),598 'task': kw.get('task', None),599 'forihostid': kw.get('forihostid', 0),600 'ihost_uuid': kw.get('ihost_uuid', '1be26c0b-03f2-4d2e-ae87-c02d7f33c781'),601 'hostname': kw.get('hostname', 'controller-0'),602 }603 return mon604def get_test_lvg(**kw):605 lvg = {606 'id': kw.get('id', 2),607 'uuid': kw.get('uuid'),608 'lvm_vg_name': kw.get('lvm_vg_name'),609 'forihostid': kw.get('forihostid', 2),610 }611 return lvg612def create_test_lvg(**kw):613 """Create test lvg entry in DB and return LogicalVolumeGroup DB object.614 Function to be used to create test objects in the database.615 :param kw: kwargs with overriding values for attributes.616 kw requires: lvm_vg_name617 :returns: Test LogicalVolumeGroup DB object.618 """619 lvg = get_test_lvg(**kw)620 if 'uuid' not in kw:621 del lvg['uuid']622 dbapi = db_api.get_instance()623 forihostid = lvg['forihostid']624 return dbapi.ilvg_create(forihostid, lvg)625def get_test_pv(**kw):626 pv = {627 'id': kw.get('id', 2),628 'uuid': kw.get('uuid'),629 'lvm_vg_name': kw.get('lvm_vg_name'),630 'disk_or_part_uuid': kw.get('disk_or_part_uuid', str(uuid.uuid4())),631 'disk_or_part_device_path': kw.get('disk_or_part_device_path',632 '/dev/disk/by-path/pci-0000:00:0d.0-ata-3.0'),633 'forihostid': kw.get('forihostid', 2),634 'forilvgid': kw.get('forilvgid', 2),635 }636 return pv637def create_test_pv(**kw):638 """Create test pv entry in DB and return PV DB object.639 Function to be used to create test PV objects in the database.640 :param kw: kwargs with overriding values for pv's attributes.641 kw typically requires forihostid, forilvgid642 :returns: Test PV DB object.643 """644 pv = get_test_pv(**kw)645 if 'uuid' not in kw:646 del pv['uuid']647 dbapi = db_api.get_instance()648 forihostid = pv['forihostid']649 return dbapi.ipv_create(forihostid, pv)650def post_get_test_pv(**kw):651 pv = get_test_pv(**kw)652 # When invoking a POST the following fields should not be populated:653 del pv['uuid']654 del pv['id']655 return pv656def get_test_storage_backend(**kw):657 inv = {658 'id': kw.get('id'),659 'uuid': kw.get('uuid'),660 'backend': kw.get('backend', None),661 'state': kw.get('state', None),662 'task': kw.get('task', None),663 'services': kw.get('services', None),664 'capabilities': kw.get('capabilities', {}),665 'forisystemid': kw.get('forisystemid', None)666 }667 return inv668def get_test_ceph_storage_backend(**kw):669 inv = {670 'id': kw.get('id', 2),671 'uuid': kw.get('uuid'),672 'name': kw.get('name', constants.SB_DEFAULT_NAMES[constants.SB_TYPE_CEPH]),673 'backend': kw.get('backend', constants.SB_TYPE_CEPH),674 'state': kw.get('state', None),675 'task': kw.get('task', None),676 'services': kw.get('services', None),677 'tier_id': kw.get('tier_id'),678 'capabilities': kw.get('capabilities', constants.CEPH_BACKEND_CAP_DEFAULT),679 'forisystemid': kw.get('forisystemid', None),680 'cinder_pool_gib': kw.get('cinder_pool_gib', 80),681 'glance_pool_gib': kw.get('glance_pool_gib', 10),682 'ephemeral_pool_gib': kw.get('ephemeral_pool_gib', 0),683 'object_pool_gib': kw.get('object_pool_gib', 0),684 'object_gateway': kw.get('object_gateway', False)685 }686 return inv687def get_test_file_storage_backend(**kw):688 inv = {689 'id': kw.get('id', 3),690 'uuid': kw.get('uuid'),691 'name': kw.get('name', constants.SB_DEFAULT_NAMES[constants.SB_TYPE_FILE]),692 'backend': kw.get('backend', constants.SB_TYPE_FILE),693 'state': kw.get('state', None),694 'task': kw.get('task', None),695 'services': kw.get('services', None),696 'capabilities': kw.get('capabilities', {}),697 'forisystemid': kw.get('forisystemid', None)698 }699 return inv700def get_test_lvm_storage_backend(**kw):701 inv = {702 'id': kw.get('id', 4),703 'uuid': kw.get('uuid'),704 'name': kw.get('name', constants.SB_DEFAULT_NAMES[constants.SB_TYPE_LVM]),705 'backend': kw.get('backend', constants.SB_TYPE_LVM),706 'state': kw.get('state', None),707 'task': kw.get('task', None),708 'services': kw.get('services', None),709 'capabilities': kw.get('capabilities', {}),710 'forisystemid': kw.get('forisystemid', None)711 }712 return inv713def get_test_port(**kw):714 port = {715 'id': kw.get('id', 987),716 'uuid': kw.get('uuid', '1be26c0b-03f2-4d2e-ae87-c02d7f33c781'),717 'host_id': kw.get('host_id'),718 'node_id': kw.get('node_id'),719 'interface_id': kw.get('interface_id'),720 'name': kw.get('name'),721 'pciaddr': kw.get('pciaddr'),722 'pclass': kw.get('pclass'),723 'pvendor': kw.get('pvendor'),724 'psdevice': kw.get('psdevice'),725 'dpdksupport': kw.get('dpdksupport'),726 'numa_node': kw.get('numa_node'),727 'dev_id': kw.get('dev_id'),728 'sriov_totalvfs': kw.get('sriov_totalvfs'),729 'sriov_numvfs': kw.get('sriov_numvfs'),730 'sriov_vfs_pci_address': kw.get('sriov_vfs_pci_address'),731 'sriov_vf_driver': kw.get('sriov_vf_driver'),732 'sriov_vf_pdevice_id': kw.get('sriov_vf_pdevice_id'),733 'driver': kw.get('driver'),734 'capabilities': kw.get('capabilities'),735 'created_at': kw.get('created_at'),736 'updated_at': kw.get('updated_at'),737 }738 return port739def get_test_chassis(**kw):740 chassis = {741 'id': kw.get('id', 42),742 'uuid': kw.get('uuid', 'e74c40e0-d825-11e2-a28f-0800200c9a66'),743 'extra': kw.get('extra', {}),744 'description': kw.get('description', 'data-center-1-chassis'),745 'created_at': kw.get('created_at'),746 'updated_at': kw.get('updated_at'),747 }748 return chassis749def get_test_ethernet_port(**kw):750 ethernet_port = {751 'id': kw.get('id', 24),752 'mac': kw.get('mac', '08:00:27:ea:93:8e'),753 'mtu': kw.get('mtu', '1500'),754 'speed': kw.get('speed', 1000),755 'link_mode': kw.get('link_mode', 0),756 'duplex': kw.get('duplex', None),757 'autoneg': kw.get('autoneg', None),758 'bootp': kw.get('bootp', None),759 'name': kw.get('name'),760 'host_id': kw.get('host_id'),761 'interface_id': kw.get('interface_id'),762 'interface_uuid': kw.get('interface_uuid'),763 'pciaddr': kw.get('pciaddr'),764 'dpdksupport': kw.get('dpdksupport'),765 'dev_id': kw.get('dev_id'),766 'sriov_totalvfs': kw.get('sriov_totalvfs'),767 'sriov_numvfs': kw.get('sriov_numvfs'),768 'sriov_vf_driver': kw.get('sriov_vf_driver'),769 'sriov_vf_pdevice_id': kw.get('sriov_vf_pdevice_id'),770 'driver': kw.get('driver'),771 'numa_node': kw.get('numa_node', -1)772 }773 return ethernet_port774def get_test_datanetwork(**kw):775 datanetwork = {776 'uuid': kw.get('uuid', '60d41820-a4a0-4c25-a6a0-2a3b98746640'),777 'name': kw.get('name'),778 'network_type': kw.get('network_type', 'vxlan'),779 'mtu': kw.get('mtu', '1500'),780 'multicast_group': kw.get('multicast_group', '239.0.2.1'),781 'port_num': kw.get('port_num', 8472),782 'ttl': kw.get('ttl', 10),783 'mode': kw.get('mode', 'dynamic'),784 }785 return datanetwork786def create_test_datanetwork(**kw):787 """Create test datanetwork entry in DB and return datanetwork DB object.788 Function to be used to create test datanetwork objects in the database.789 :param kw: kwargs with overriding values for datanework attributes.790 :returns: Test datanetwork DB object.791 """792 datanetwork = get_test_datanetwork(**kw)793 if kw['network_type'] != constants.DATANETWORK_TYPE_VXLAN:794 # Remove DB fields which are specific to VXLAN795 del datanetwork['multicast_group']796 del datanetwork['port_num']797 del datanetwork['ttl']798 del datanetwork['mode']799 dbapi = db_api.get_instance()800 return dbapi.datanetwork_create(datanetwork)801def create_test_ethernet_port(**kw):802 """Create test ethernet port entry in DB and return ethernet port DB object.803 Function to be used to create test ethernet port objects in the database.804 :param kw: kwargs with overriding values for ethernet port's attributes.805 :returns: Test ethernet port DB object.806 """807 ethernet_port = get_test_ethernet_port(**kw)808 # Let DB generate ID if it isn't specified explicitly809 if 'id' not in kw:810 del ethernet_port['id']811 dbapi = db_api.get_instance()812 return dbapi.ethernet_port_create(ethernet_port['host_id'], ethernet_port)813def get_test_interface(**kw):814 interface = {815 'id': kw.get('id'),816 'uuid': kw.get('uuid'),817 'forihostid': kw.get('forihostid'),818 'ihost_uuid': kw.get('ihost_uuid'),819 'ifname': kw.get('ifname', 'enp0s3'),820 'iftype': kw.get('iftype', 'ethernet'),821 'imac': kw.get('imac', '11:22:33:44:55:66'),822 'imtu': kw.get('imtu', 1500),823 'ifclass': kw.get('ifclass', None),824 'networktypelist': kw.get('networktypelist', []),825 'aemode': kw.get('aemode'),826 'txhashpolicy': kw.get('txhashpolicy', None),827 'vlan_id': kw.get('vlan_id', None),828 'uses': kw.get('uses', []),829 'used_by': kw.get('used_by', []),830 'ipv4_mode': kw.get('ipv4_mode'),831 'ipv6_mode': kw.get('ipv6_mode'),832 'ipv4_pool': kw.get('ipv4_pool'),833 'ipv6_pool': kw.get('ipv6_pool'),834 'sriov_numvfs': kw.get('sriov_numvfs', None),835 'sriov_vf_driver': kw.get('sriov_vf_driver', None),836 'sriov_vf_pdevice_id': kw.get('sriov_vf_pdevice_id', None),837 'ptp_role': kw.get('ptp_role', None)838 }839 return interface840def create_test_interface(**kw):841 """Create test interface entry in DB and return Interface DB object.842 Function to be used to create test Interface objects in the database.843 :param kw: kwargs with overriding values for interface's attributes.844 :returns: Test Interface DB object.845 """846 interface = get_test_interface(**kw)847 datanetworks_list = interface.get('datanetworks') or []848 networks_list = interface.get('networks') or []849 # Let DB generate ID if it isn't specified explicitly850 if 'id' not in kw:851 del interface['id']852 if 'datanetworks' in interface:853 del interface['datanetworks']854 if 'networks' in interface:855 del interface['networks']856 dbapi = db_api.get_instance()857 forihostid = kw.get('forihostid')858 interface_obj = dbapi.iinterface_create(forihostid, interface)859 # assign the network to the interface860 for network in networks_list:861 if not network:862 continue863 net = dbapi.network_get(network)864 values = {'interface_id': interface_obj.id,865 'network_id': net.id}866 dbapi.interface_network_create(values)867 # assign the interface to the datanetwork868 for datanetwork in datanetworks_list:869 if not datanetwork:870 continue871 dn = dbapi.datanetwork_get(datanetwork)872 values = {'interface_id': interface_obj.id,873 'datanetwork_id': dn.id}874 dbapi.interface_datanetwork_create(values)875 return interface_obj876def create_test_interface_network(**kw):877 """Create test network interface entry in DB and return Network DB878 object. Function to be used to create test Network objects in the database.879 :param kw: kwargs with overriding values for network's attributes.880 :returns: Test Network DB object.881 """882 interface_network = get_test_interface_network(**kw)883 if 'id' not in kw:884 del interface_network['id']885 dbapi = db_api.get_instance()886 return dbapi.interface_network_create(interface_network)887def get_test_interface_network(**kw):888 inv = {889 'id': kw.get('id'),890 'uuid': kw.get('uuid'),891 'interface_id': kw.get('interface_id'),892 'network_id': kw.get('network_id'),893 }894 return inv895def post_get_test_interface_network(**kw):896 inv = {897 'interface_uuid': kw.get('interface_uuid'),898 'network_uuid': kw.get('network_uuid'),899 }900 return inv901def get_test_partition(**kw):902 """get_test_partition will fail unless903 forihostid is provided904 disk_id is provided905 size_mib must be a valid number906 """907 partition = {908 'uuid': kw.get('uuid'),909 'start_mib': kw.get('start_mib'),910 'end_mib': kw.get('end_mib'),911 'size_mib': kw.get('size_mib'),912 'device_path': kw.get('device_path'),913 'device_node': kw.get('device_node'),914 'forihostid': kw.get('forihostid'),915 'idisk_id': kw.get('idisk_id'),916 'idisk_uuid': kw.get('idisk_uuid'),917 'type_guid': kw.get('type_guid'),918 'status': kw.get('status',919 constants.PARTITION_CREATE_ON_UNLOCK_STATUS),920 }921 return partition922def create_test_partition(**kw):923 """Create test partition entry in DB and return Partition DB924 object. Function to be used to create test Partition objects in the database.925 :param kw: kwargs with overriding values for partition's attributes.926 :returns: Test Partition DB object.927 """928 partition = get_test_partition(**kw)929 if 'uuid' not in kw:930 del partition['uuid']931 dbapi = db_api.get_instance()932 forihostid = partition['forihostid']933 return dbapi.partition_create(forihostid, partition)934def post_get_test_partition(**kw):935 partition = get_test_partition(**kw)936 # When invoking a POST the following fields should not be populated:937 del partition['uuid']938 del partition['status']939 return partition940def get_test_interface_datanetwork(**kw):941 inv = {942 'id': kw.get('id'),943 'uuid': kw.get('uuid'),944 'interface_uuid': kw.get('interface_uuid'),945 'datanetwork_uuid': kw.get('datanetwork_uuid'),946 }947 return inv948def create_test_interface_datanetwork(**kw):949 """Create test network interface entry in DB and return Network DB950 object. Function to be used to create test Network objects in the database.951 :param kw: kwargs with overriding values for network's attributes.952 :returns: Test Network DB object.953 """954 interface_datanetwork = get_test_interface_datanetwork(**kw)955 if 'id' not in kw:956 del interface_datanetwork['id']957 dbapi = db_api.get_instance()958 return dbapi.interface_datanetwork_create(interface_datanetwork)959def post_get_test_interface_datanetwork(**kw):960 inv = {961 'interface_uuid': kw.get('interface_uuid'),962 'datanetwork_uuid': kw.get('datanetwork_uuid'),963 }964 return inv965def get_test_storage_tier(**kw):966 tier = {967 'id': kw.get('id', 321),968 'uuid': kw.get('uuid'),969 'name': kw.get('name', constants.SB_TIER_DEFAULT_NAMES[constants.SB_TYPE_CEPH]),970 'type': kw.get('type', constants.SB_TYPE_CEPH),971 'status': kw.get('status', constants.SB_TIER_STATUS_DEFINED),972 'capabilities': kw.get('capabilities', {}),973 'forclusterid': kw.get('forclusterid'),974 'cluster_uuid': kw.get('cluster_uuid'),975 'forbackendid': kw.get('forbackendid'),976 'backend_uuid': kw.get('backend_uuid'),977 }978 return tier979def create_test_storage_tier(**kw):980 """Create test storage_tier entry in DB and return storage_tier DB object.981 Function to be used to create test storage_tier objects in the database.982 :param kw: kwargs with overriding values for system's attributes.983 :returns: Test System DB object.984 """985 storage_tier = get_test_storage_tier(**kw)986 # Let DB generate ID if it isn't specified explicitly987 if 'id' not in kw:988 del storage_tier['id']989 dbapi = db_api.get_instance()990 return dbapi.storage_tier_create(storage_tier)991def get_test_cluster(**kw):992 cluster = {993 'id': kw.get('id', 321),994 'uuid': kw.get('uuid'),995 'name': kw.get('name'),996 'type': kw.get('type', constants.SB_TYPE_CEPH),997 'capabilities': kw.get('capabilities', {}),998 'system_id': kw.get('system_id'),999 'cluster_uuid': kw.get('cluster_uuid'),1000 }1001 return cluster1002def create_test_cluster(**kw):1003 """Create test cluster entry in DB and return System DB object.1004 Function to be used to create test cluster objects in the database.1005 :param kw: kwargs with overriding values for system's attributes.1006 :returns: Test System DB object.1007 """1008 cluster = get_test_cluster(**kw)1009 # Let DB generate ID if it isn't specified explicitly1010 if 'id' not in kw:1011 del cluster['id']1012 dbapi = db_api.get_instance()1013 return dbapi.cluster_create(cluster)1014def get_test_app(**kw):1015 app_data = {1016 'id': kw.get('id', 90210),1017 'name': kw.get('name', 'stx-openstack'),1018 'app_version': kw.get('app_version',1019 constants.APP_VERSION_PLACEHOLDER),1020 'manifest_name': kw.get('manifest_name',1021 constants.APP_MANIFEST_NAME_PLACEHOLDER),1022 'manifest_file': kw.get('manifest_file',1023 constants.APP_TARFILE_NAME_PLACEHOLDER),1024 'status': kw.get('status', constants.APP_UPLOAD_IN_PROGRESS),1025 'active': kw.get('active', False),1026 }1027 return app_data1028def create_test_app(**kw):1029 """Create test application entry in DB and return Application DB object.1030 Function to be used to create test application objects in the database.1031 :param kw: kwargs with overriding values for application attributes.1032 :returns: Test Application DB object.1033 """1034 app_data = get_test_app(**kw)1035 # Let DB generate ID if it isn't specified explicitly1036 if 'id' not in kw:1037 del app_data['id']1038 dbapi = db_api.get_instance()1039 return dbapi.kube_app_create(app_data)1040def get_test_pci_devices(**kw):1041 pci_devices = {1042 'id': kw.get('id', 2345),1043 'host_id': kw.get('host_id', 2),1044 'name': kw.get('name', 'pci_0000_00_02_0 '),1045 'pciaddr': kw.get('pciaddr', '0000:00:02.0'),1046 'pclass_id': kw.get('pclass_id', '030000'),1047 'pvendor_id': kw.get('pvendor_id', '8086'),1048 'pdevice_id': kw.get('pdevice_id', '3ea5'),1049 'pclass': kw.get('pclass', 'VGA compatible controller'),1050 'pvendor': kw.get('pvendor', 'Intel Corporation'),1051 'pdevice': kw.get('pdevice', 'Iris Plus Graphics 655'),1052 'numa_node': kw.get('numa_node', -1),1053 'enabled': kw.get('enabled', True),1054 'driver': kw.get('driver', '')1055 }1056 return pci_devices1057def create_test_pci_devices(**kw):1058 """Create test pci devices entry in DB and return PciDevice DB object.1059 Function to be used to create test pci device objects in the database.1060 :param kw: kwargs with overriding values for pci device attributes.1061 :returns: Test PciDevice DB object.1062 """1063 pci_devices = get_test_pci_devices(**kw)1064 # Let DB generate ID if it isn't specified explicitly1065 if 'id' not in kw:1066 del pci_devices['id']1067 dbapi = db_api.get_instance()1068 return dbapi.pci_device_create(pci_devices['host_id'], pci_devices)1069def get_test_label(**kw):1070 label = {1071 'host_id': kw.get('host_id'),1072 'label_key': kw.get('label_key'),1073 'label_value': kw.get('label_value'),1074 }1075 return label1076def create_test_label(**kw):1077 """Create test label in DB and return label object.1078 Function to be used to create test label objects in the database.1079 :param kw: kwargs with overriding values for labels's attributes.1080 :returns: Test label DB object.1081 """1082 label = get_test_label(**kw)1083 dbapi = db_api.get_instance()1084 return dbapi.label_create(label['host_id'], label)1085def create_test_oam(**kw):1086 dbapi = db_api.get_instance()...

Full Screen

Full Screen

c_config.py

Source:c_config.py Github

copy

Full Screen

1#! /usr/bin/env python2# encoding: utf-83# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file4import os,re,shlex,sys5from waflib import Build,Utils,Task,Options,Logs,Errors,ConfigSet,Runner6from waflib.TaskGen import after_method,feature7from waflib.Configure import conf8WAF_CONFIG_H='config.h'9DEFKEYS='define_key'10INCKEYS='include_key'11cfg_ver={'atleast-version':'>=','exact-version':'==','max-version':'<=',}12SNIP_FUNCTION='''13int main(int argc, char **argv) {14 void *p;15 (void)argc; (void)argv;16 p=(void*)(%s);17 return 0;18}19'''20SNIP_TYPE='''21int main(int argc, char **argv) {22 (void)argc; (void)argv;23 if ((%(type_name)s *) 0) return 0;24 if (sizeof (%(type_name)s)) return 0;25 return 1;26}27'''28SNIP_EMPTY_PROGRAM='''29int main(int argc, char **argv) {30 (void)argc; (void)argv;31 return 0;32}33'''34SNIP_FIELD='''35int main(int argc, char **argv) {36 char *off;37 (void)argc; (void)argv;38 off = (char*) &((%(type_name)s*)0)->%(field_name)s;39 return (size_t) off < sizeof(%(type_name)s);40}41'''42MACRO_TO_DESTOS={'__linux__':'linux','__GNU__':'gnu','__FreeBSD__':'freebsd','__NetBSD__':'netbsd','__OpenBSD__':'openbsd','__sun':'sunos','__hpux':'hpux','__sgi':'irix','_AIX':'aix','__CYGWIN__':'cygwin','__MSYS__':'msys','_UWIN':'uwin','_WIN64':'win32','_WIN32':'win32','__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__':'darwin','__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__':'darwin','__QNX__':'qnx','__native_client__':'nacl'}43MACRO_TO_DEST_CPU={'__x86_64__':'x86_64','__amd64__':'x86_64','__i386__':'x86','__ia64__':'ia','__mips__':'mips','__sparc__':'sparc','__alpha__':'alpha','__aarch64__':'aarch64','__thumb__':'thumb','__arm__':'arm','__hppa__':'hppa','__powerpc__':'powerpc','__ppc__':'powerpc','__convex__':'convex','__m68k__':'m68k','__s390x__':'s390x','__s390__':'s390','__sh__':'sh',}44@conf45def parse_flags(self,line,uselib_store,env=None,force_static=False):46 assert(isinstance(line,str))47 env=env or self.env48 app=env.append_value49 appu=env.append_unique50 lex=shlex.shlex(line,posix=False)51 lex.whitespace_split=True52 lex.commenters=''53 lst=list(lex)54 uselib=uselib_store55 while lst:56 x=lst.pop(0)57 st=x[:2]58 ot=x[2:]59 if st=='-I'or st=='/I':60 if not ot:ot=lst.pop(0)61 appu('INCLUDES_'+uselib,[ot])62 elif st=='-include':63 tmp=[x,lst.pop(0)]64 app('CFLAGS',tmp)65 app('CXXFLAGS',tmp)66 elif st=='-D'or(env.CXX_NAME=='msvc'and st=='/D'):67 if not ot:ot=lst.pop(0)68 app('DEFINES_'+uselib,[ot])69 elif st=='-l':70 if not ot:ot=lst.pop(0)71 prefix=force_static and'STLIB_'or'LIB_'72 appu(prefix+uselib,[ot])73 elif st=='-L':74 if not ot:ot=lst.pop(0)75 appu('LIBPATH_'+uselib,[ot])76 elif x.startswith('/LIBPATH:'):77 appu('LIBPATH_'+uselib,[x.replace('/LIBPATH:','')])78 elif x=='-pthread'or x.startswith('+')or x.startswith('-std'):79 app('CFLAGS_'+uselib,[x])80 app('CXXFLAGS_'+uselib,[x])81 app('LINKFLAGS_'+uselib,[x])82 elif x=='-framework':83 appu('FRAMEWORK_'+uselib,[lst.pop(0)])84 elif x.startswith('-F'):85 appu('FRAMEWORKPATH_'+uselib,[x[2:]])86 elif x.startswith('-Wl'):87 app('LINKFLAGS_'+uselib,[x])88 elif x.startswith('-m')or x.startswith('-f')or x.startswith('-dynamic'):89 app('CFLAGS_'+uselib,[x])90 app('CXXFLAGS_'+uselib,[x])91 elif x.startswith('-bundle'):92 app('LINKFLAGS_'+uselib,[x])93 elif x.startswith('-undefined'):94 arg=lst.pop(0)95 app('LINKFLAGS_'+uselib,[x,arg])96 elif x.startswith('-arch')or x.startswith('-isysroot'):97 tmp=[x,lst.pop(0)]98 app('CFLAGS_'+uselib,tmp)99 app('CXXFLAGS_'+uselib,tmp)100 app('LINKFLAGS_'+uselib,tmp)101 elif x.endswith('.a')or x.endswith('.so')or x.endswith('.dylib')or x.endswith('.lib'):102 appu('LINKFLAGS_'+uselib,[x])103@conf104def ret_msg(self,f,kw):105 if isinstance(f,str):106 return f107 return f(kw)108@conf109def validate_cfg(self,kw):110 if not'path'in kw:111 if not self.env.PKGCONFIG:112 self.find_program('pkg-config',var='PKGCONFIG')113 kw['path']=self.env.PKGCONFIG114 if'atleast_pkgconfig_version'in kw:115 if not'msg'in kw:116 kw['msg']='Checking for pkg-config version >= %r'%kw['atleast_pkgconfig_version']117 return118 if not'okmsg'in kw:119 kw['okmsg']='yes'120 if not'errmsg'in kw:121 kw['errmsg']='not found'122 if'modversion'in kw:123 if not'msg'in kw:124 kw['msg']='Checking for %r version'%kw['modversion']125 return126 for x in cfg_ver.keys():127 y=x.replace('-','_')128 if y in kw:129 if not'package'in kw:130 raise ValueError('%s requires a package'%x)131 if not'msg'in kw:132 kw['msg']='Checking for %r %s %s'%(kw['package'],cfg_ver[x],kw[y])133 return134 if not'msg'in kw:135 kw['msg']='Checking for %r'%(kw['package']or kw['path'])136@conf137def exec_cfg(self,kw):138 def define_it():139 self.define(self.have_define(kw.get('uselib_store',kw['package'])),1,0)140 if'atleast_pkgconfig_version'in kw:141 cmd=[kw['path'],'--atleast-pkgconfig-version=%s'%kw['atleast_pkgconfig_version']]142 self.cmd_and_log(cmd)143 if not'okmsg'in kw:144 kw['okmsg']='yes'145 return146 for x in cfg_ver:147 y=x.replace('-','_')148 if y in kw:149 self.cmd_and_log([kw['path'],'--%s=%s'%(x,kw[y]),kw['package']])150 if not'okmsg'in kw:151 kw['okmsg']='yes'152 define_it()153 break154 if'modversion'in kw:155 version=self.cmd_and_log([kw['path'],'--modversion',kw['modversion']]).strip()156 self.define('%s_VERSION'%Utils.quote_define_name(kw.get('uselib_store',kw['modversion'])),version)157 return version158 lst=[kw['path']]159 defi=kw.get('define_variable',None)160 if not defi:161 defi=self.env.PKG_CONFIG_DEFINES or{}162 for key,val in defi.items():163 lst.append('--define-variable=%s=%s'%(key,val))164 if'variables'in kw:165 env=kw.get('env',self.env)166 uselib=kw.get('uselib_store',kw['package'].upper())167 vars=Utils.to_list(kw['variables'])168 for v in vars:169 val=self.cmd_and_log(lst+['--variable='+v]).strip()170 var='%s_%s'%(uselib,v)171 env[var]=val172 if not'okmsg'in kw:173 kw['okmsg']='yes'174 return175 static=False176 if'args'in kw:177 args=Utils.to_list(kw['args'])178 if'--static'in args or'--static-libs'in args:179 static=True180 lst+=args181 lst.extend(Utils.to_list(kw['package']))182 ret=self.cmd_and_log(lst)183 if not'okmsg'in kw:184 kw['okmsg']='yes'185 define_it()186 self.parse_flags(ret,kw.get('uselib_store',kw['package'].upper()),kw.get('env',self.env),force_static=static)187 return ret188@conf189def check_cfg(self,*k,**kw):190 if k:191 lst=k[0].split()192 kw['package']=lst[0]193 kw['args']=' '.join(lst[1:])194 self.validate_cfg(kw)195 if'msg'in kw:196 self.start_msg(kw['msg'])197 ret=None198 try:199 ret=self.exec_cfg(kw)200 except self.errors.WafError:201 if'errmsg'in kw:202 self.end_msg(kw['errmsg'],'YELLOW')203 if Logs.verbose>1:204 raise205 else:206 self.fatal('The configuration failed')207 else:208 kw['success']=ret209 if'okmsg'in kw:210 self.end_msg(self.ret_msg(kw['okmsg'],kw))211 return ret212@conf213def validate_c(self,kw):214 if not'env'in kw:215 kw['env']=self.env.derive()216 env=kw['env']217 if not'compiler'in kw and not'features'in kw:218 kw['compiler']='c'219 if env['CXX_NAME']and Task.classes.get('cxx',None):220 kw['compiler']='cxx'221 if not self.env['CXX']:222 self.fatal('a c++ compiler is required')223 else:224 if not self.env['CC']:225 self.fatal('a c compiler is required')226 if not'compile_mode'in kw:227 kw['compile_mode']='c'228 if'cxx'in Utils.to_list(kw.get('features',[]))or kw.get('compiler','')=='cxx':229 kw['compile_mode']='cxx'230 if not'type'in kw:231 kw['type']='cprogram'232 if not'features'in kw:233 kw['features']=[kw['compile_mode'],kw['type']]234 else:235 kw['features']=Utils.to_list(kw['features'])236 if not'compile_filename'in kw:237 kw['compile_filename']='test.c'+((kw['compile_mode']=='cxx')and'pp'or'')238 def to_header(dct):239 if'header_name'in dct:240 dct=Utils.to_list(dct['header_name'])241 return''.join(['#include <%s>\n'%x for x in dct])242 return''243 if'framework_name'in kw:244 fwkname=kw['framework_name']245 if not'uselib_store'in kw:246 kw['uselib_store']=fwkname.upper()247 if not kw.get('no_header',False):248 if not'header_name'in kw:249 kw['header_name']=[]250 fwk='%s/%s.h'%(fwkname,fwkname)251 if kw.get('remove_dot_h',None):252 fwk=fwk[:-2]253 kw['header_name']=Utils.to_list(kw['header_name'])+[fwk]254 kw['msg']='Checking for framework %s'%fwkname255 kw['framework']=fwkname256 if'function_name'in kw:257 fu=kw['function_name']258 if not'msg'in kw:259 kw['msg']='Checking for function %s'%fu260 kw['code']=to_header(kw)+SNIP_FUNCTION%fu261 if not'uselib_store'in kw:262 kw['uselib_store']=fu.upper()263 if not'define_name'in kw:264 kw['define_name']=self.have_define(fu)265 elif'type_name'in kw:266 tu=kw['type_name']267 if not'header_name'in kw:268 kw['header_name']='stdint.h'269 if'field_name'in kw:270 field=kw['field_name']271 kw['code']=to_header(kw)+SNIP_FIELD%{'type_name':tu,'field_name':field}272 if not'msg'in kw:273 kw['msg']='Checking for field %s in %s'%(field,tu)274 if not'define_name'in kw:275 kw['define_name']=self.have_define((tu+'_'+field).upper())276 else:277 kw['code']=to_header(kw)+SNIP_TYPE%{'type_name':tu}278 if not'msg'in kw:279 kw['msg']='Checking for type %s'%tu280 if not'define_name'in kw:281 kw['define_name']=self.have_define(tu.upper())282 elif'header_name'in kw:283 if not'msg'in kw:284 kw['msg']='Checking for header %s'%kw['header_name']285 l=Utils.to_list(kw['header_name'])286 assert len(l)>0,'list of headers in header_name is empty'287 kw['code']=to_header(kw)+SNIP_EMPTY_PROGRAM288 if not'uselib_store'in kw:289 kw['uselib_store']=l[0].upper()290 if not'define_name'in kw:291 kw['define_name']=self.have_define(l[0])292 if'lib'in kw:293 if not'msg'in kw:294 kw['msg']='Checking for library %s'%kw['lib']295 if not'uselib_store'in kw:296 kw['uselib_store']=kw['lib'].upper()297 if'stlib'in kw:298 if not'msg'in kw:299 kw['msg']='Checking for static library %s'%kw['stlib']300 if not'uselib_store'in kw:301 kw['uselib_store']=kw['stlib'].upper()302 if'fragment'in kw:303 kw['code']=kw['fragment']304 if not'msg'in kw:305 kw['msg']='Checking for code snippet'306 if not'errmsg'in kw:307 kw['errmsg']='no'308 for(flagsname,flagstype)in[('cxxflags','compiler'),('cflags','compiler'),('linkflags','linker')]:309 if flagsname in kw:310 if not'msg'in kw:311 kw['msg']='Checking for %s flags %s'%(flagstype,kw[flagsname])312 if not'errmsg'in kw:313 kw['errmsg']='no'314 if not'execute'in kw:315 kw['execute']=False316 if kw['execute']:317 kw['features'].append('test_exec')318 if not'errmsg'in kw:319 kw['errmsg']='not found'320 if not'okmsg'in kw:321 kw['okmsg']='yes'322 if not'code'in kw:323 kw['code']=SNIP_EMPTY_PROGRAM324 if self.env[INCKEYS]:325 kw['code']='\n'.join(['#include <%s>'%x for x in self.env[INCKEYS]])+'\n'+kw['code']326 if not kw.get('success'):kw['success']=None327 if'define_name'in kw:328 self.undefine(kw['define_name'])329 assert'msg'in kw,'invalid parameters, read http://freehackers.org/~tnagy/wafbook/single.html#config_helpers_c'330@conf331def post_check(self,*k,**kw):332 is_success=0333 if kw['execute']:334 if kw['success']is not None:335 if kw.get('define_ret',False):336 is_success=kw['success']337 else:338 is_success=(kw['success']==0)339 else:340 is_success=(kw['success']==0)341 if'define_name'in kw:342 if'header_name'in kw or'function_name'in kw or'type_name'in kw or'fragment'in kw:343 if kw['execute']and kw.get('define_ret',None)and isinstance(is_success,str):344 self.define(kw['define_name'],is_success,quote=kw.get('quote',1))345 else:346 self.define_cond(kw['define_name'],is_success)347 else:348 self.define_cond(kw['define_name'],is_success)349 if'header_name'in kw:350 if kw.get('auto_add_header_name',False):351 self.env.append_value(INCKEYS,Utils.to_list(kw['header_name']))352 if is_success and'uselib_store'in kw:353 from waflib.Tools import ccroot354 _vars=set([])355 for x in kw['features']:356 if x in ccroot.USELIB_VARS:357 _vars|=ccroot.USELIB_VARS[x]358 for k in _vars:359 lk=k.lower()360 if k=='INCLUDES':lk='includes'361 if k=='DEFINES':lk='defines'362 if lk in kw:363 val=kw[lk]364 if isinstance(val,str):365 val=val.rstrip(os.path.sep)366 self.env.append_unique(k+'_'+kw['uselib_store'],val)367 return is_success368@conf369def check(self,*k,**kw):370 self.validate_c(kw)371 self.start_msg(kw['msg'])372 ret=None373 try:374 ret=self.run_c_code(*k,**kw)375 except self.errors.ConfigurationError:376 self.end_msg(kw['errmsg'],'YELLOW')377 if Logs.verbose>1:378 raise379 else:380 self.fatal('The configuration failed')381 else:382 kw['success']=ret383 ret=self.post_check(*k,**kw)384 if not ret:385 self.end_msg(kw['errmsg'],'YELLOW')386 self.fatal('The configuration failed %r'%ret)387 else:388 self.end_msg(self.ret_msg(kw['okmsg'],kw))389 return ret390class test_exec(Task.Task):391 color='PINK'392 def run(self):393 if getattr(self.generator,'rpath',None):394 if getattr(self.generator,'define_ret',False):395 self.generator.bld.retval=self.generator.bld.cmd_and_log([self.inputs[0].abspath()])396 else:397 self.generator.bld.retval=self.generator.bld.exec_command([self.inputs[0].abspath()])398 else:399 env=self.env.env or{}400 env.update(dict(os.environ))401 for var in('LD_LIBRARY_PATH','DYLD_LIBRARY_PATH','PATH'):402 env[var]=self.inputs[0].parent.abspath()+os.path.pathsep+env.get(var,'')403 if getattr(self.generator,'define_ret',False):404 self.generator.bld.retval=self.generator.bld.cmd_and_log([self.inputs[0].abspath()],env=env)405 else:406 self.generator.bld.retval=self.generator.bld.exec_command([self.inputs[0].abspath()],env=env)407@feature('test_exec')408@after_method('apply_link')409def test_exec_fun(self):410 self.create_task('test_exec',self.link_task.outputs[0])411CACHE_RESULTS=1412COMPILE_ERRORS=2413@conf414def run_c_code(self,*k,**kw):415 lst=[str(v)for(p,v)in kw.items()if p!='env']416 h=Utils.h_list(lst)417 dir=self.bldnode.abspath()+os.sep+(not Utils.is_win32 and'.'or'')+'conf_check_'+Utils.to_hex(h)418 try:419 os.makedirs(dir)420 except OSError:421 pass422 try:423 os.stat(dir)424 except OSError:425 self.fatal('cannot use the configuration test folder %r'%dir)426 cachemode=getattr(Options.options,'confcache',None)427 if cachemode==CACHE_RESULTS:428 try:429 proj=ConfigSet.ConfigSet(os.path.join(dir,'cache_run_c_code'))430 except OSError:431 pass432 else:433 ret=proj['cache_run_c_code']434 if isinstance(ret,str)and ret.startswith('Test does not build'):435 self.fatal(ret)436 return ret437 bdir=os.path.join(dir,'testbuild')438 if not os.path.exists(bdir):439 os.makedirs(bdir)440 self.test_bld=bld=Build.BuildContext(top_dir=dir,out_dir=bdir)441 bld.init_dirs()442 bld.progress_bar=0443 bld.targets='*'444 if kw['compile_filename']:445 node=bld.srcnode.make_node(kw['compile_filename'])446 node.write(kw['code'])447 bld.logger=self.logger448 bld.all_envs.update(self.all_envs)449 bld.env=kw['env']450 o=bld(features=kw['features'],source=kw['compile_filename'],target='testprog')451 for k,v in kw.items():452 setattr(o,k,v)453 self.to_log("==>\n%s\n<=="%kw['code'])454 bld.targets='*'455 ret=-1456 try:457 try:458 bld.compile()459 except Errors.WafError:460 ret='Test does not build: %s'%Utils.ex_stack()461 self.fatal(ret)462 else:463 ret=getattr(bld,'retval',0)464 finally:465 proj=ConfigSet.ConfigSet()466 proj['cache_run_c_code']=ret467 proj.store(os.path.join(dir,'cache_run_c_code'))468 return ret469@conf470def check_cxx(self,*k,**kw):471 kw['compiler']='cxx'472 return self.check(*k,**kw)473@conf474def check_cc(self,*k,**kw):475 kw['compiler']='c'476 return self.check(*k,**kw)477@conf478def define(self,key,val,quote=True):479 assert key and isinstance(key,str)480 if val is True:481 val=1482 elif val in(False,None):483 val=0484 if isinstance(val,int)or isinstance(val,float):485 s='%s=%s'486 else:487 s=quote and'%s="%s"'or'%s=%s'488 app=s%(key,str(val))489 ban=key+'='490 lst=self.env['DEFINES']491 for x in lst:492 if x.startswith(ban):493 lst[lst.index(x)]=app494 break495 else:496 self.env.append_value('DEFINES',app)497 self.env.append_unique(DEFKEYS,key)498@conf499def undefine(self,key):500 assert key and isinstance(key,str)501 ban=key+'='502 lst=[x for x in self.env['DEFINES']if not x.startswith(ban)]503 self.env['DEFINES']=lst504 self.env.append_unique(DEFKEYS,key)505@conf506def define_cond(self,key,val):507 assert key and isinstance(key,str)508 if val:509 self.define(key,1)510 else:511 self.undefine(key)512@conf513def is_defined(self,key):514 assert key and isinstance(key,str)515 ban=key+'='516 for x in self.env['DEFINES']:517 if x.startswith(ban):518 return True519 return False520@conf521def get_define(self,key):522 assert key and isinstance(key,str)523 ban=key+'='524 for x in self.env['DEFINES']:525 if x.startswith(ban):526 return x[len(ban):]527 return None528@conf529def have_define(self,key):530 return(self.env.HAVE_PAT or'HAVE_%s')%Utils.quote_define_name(key)531@conf532def write_config_header(self,configfile='',guard='',top=False,env=None,defines=True,headers=False,remove=True,define_prefix=''):533 if env:534 Logs.warn('Cannot pass env to write_config_header')535 if not configfile:configfile=WAF_CONFIG_H536 waf_guard=guard or'W_%s_WAF'%Utils.quote_define_name(configfile)537 node=top and self.bldnode or self.path.get_bld()538 node=node.make_node(configfile)539 node.parent.mkdir()540 lst=['/* WARNING! All changes made to this file will be lost! */\n']541 lst.append('#ifndef %s\n#define %s\n'%(waf_guard,waf_guard))542 lst.append(self.get_config_header(defines,headers,define_prefix=define_prefix))543 lst.append('\n#endif /* %s */\n'%waf_guard)544 node.write('\n'.join(lst))545 self.env.append_unique(Build.CFG_FILES,[node.abspath()])546 if remove:547 for key in self.env[DEFKEYS]:548 self.undefine(key)549 self.env[DEFKEYS]=[]550@conf551def get_config_header(self,defines=True,headers=False,define_prefix=''):552 lst=[]553 if headers:554 for x in self.env[INCKEYS]:555 lst.append('#include <%s>'%x)556 if defines:557 for x in self.env[DEFKEYS]:558 if self.is_defined(x):559 val=self.get_define(x)560 lst.append('#define %s %s'%(define_prefix+x,val))561 else:562 lst.append('/* #undef %s */'%(define_prefix+x))563 return"\n".join(lst)564@conf565def cc_add_flags(conf):566 conf.add_os_flags('CPPFLAGS','CFLAGS')567 conf.add_os_flags('CFLAGS')568@conf569def cxx_add_flags(conf):570 conf.add_os_flags('CPPFLAGS','CXXFLAGS')571 conf.add_os_flags('CXXFLAGS')572@conf573def link_add_flags(conf):574 conf.add_os_flags('LINKFLAGS')575 conf.add_os_flags('LDFLAGS','LINKFLAGS')576@conf577def cc_load_tools(conf):578 if not conf.env.DEST_OS:579 conf.env.DEST_OS=Utils.unversioned_sys_platform()580 conf.load('c')581@conf582def cxx_load_tools(conf):583 if not conf.env.DEST_OS:584 conf.env.DEST_OS=Utils.unversioned_sys_platform()585 conf.load('cxx')586@conf587def get_cc_version(conf,cc,gcc=False,icc=False):588 cmd=cc+['-dM','-E','-']589 env=conf.env.env or None590 try:591 p=Utils.subprocess.Popen(cmd,stdin=Utils.subprocess.PIPE,stdout=Utils.subprocess.PIPE,stderr=Utils.subprocess.PIPE,env=env)592 p.stdin.write('\n')593 out=p.communicate()[0]594 except Exception:595 conf.fatal('Could not determine the compiler version %r'%cmd)596 if not isinstance(out,str):597 out=out.decode(sys.stdout.encoding or'iso8859-1')598 if gcc:599 if out.find('__INTEL_COMPILER')>=0:600 conf.fatal('The intel compiler pretends to be gcc')601 if out.find('__GNUC__')<0 and out.find('__clang__')<0:602 conf.fatal('Could not determine the compiler type')603 if icc and out.find('__INTEL_COMPILER')<0:604 conf.fatal('Not icc/icpc')605 k={}606 if icc or gcc:607 out=out.splitlines()608 for line in out:609 lst=shlex.split(line)610 if len(lst)>2:611 key=lst[1]612 val=lst[2]613 k[key]=val614 def isD(var):615 return var in k616 def isT(var):617 return var in k and k[var]!='0'618 if not conf.env.DEST_OS:619 conf.env.DEST_OS=''620 for i in MACRO_TO_DESTOS:621 if isD(i):622 conf.env.DEST_OS=MACRO_TO_DESTOS[i]623 break624 else:625 if isD('__APPLE__')and isD('__MACH__'):626 conf.env.DEST_OS='darwin'627 elif isD('__unix__'):628 conf.env.DEST_OS='generic'629 if isD('__ELF__'):630 conf.env.DEST_BINFMT='elf'631 elif isD('__WINNT__')or isD('__CYGWIN__')or isD('_WIN32'):632 conf.env.DEST_BINFMT='pe'633 conf.env.LIBDIR=conf.env.BINDIR634 elif isD('__APPLE__'):635 conf.env.DEST_BINFMT='mac-o'636 if not conf.env.DEST_BINFMT:637 conf.env.DEST_BINFMT=Utils.destos_to_binfmt(conf.env.DEST_OS)638 for i in MACRO_TO_DEST_CPU:639 if isD(i):640 conf.env.DEST_CPU=MACRO_TO_DEST_CPU[i]641 break642 Logs.debug('ccroot: dest platform: '+' '.join([conf.env[x]or'?'for x in('DEST_OS','DEST_BINFMT','DEST_CPU')]))643 if icc:644 ver=k['__INTEL_COMPILER']645 conf.env['CC_VERSION']=(ver[:-2],ver[-2],ver[-1])646 else:647 if isD('__clang__'):648 conf.env['CC_VERSION']=(k['__clang_major__'],k['__clang_minor__'],k['__clang_patchlevel__'])649 else:650 conf.env['CC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],k['__GNUC_PATCHLEVEL__'])651 return k652@conf653def get_xlc_version(conf,cc):654 cmd=cc+['-qversion']655 try:656 out,err=conf.cmd_and_log(cmd,output=0)657 except Errors.WafError:658 conf.fatal('Could not find xlc %r'%cmd)659 for v in(r"IBM XL C/C\+\+.* V(?P<major>\d*)\.(?P<minor>\d*)",):660 version_re=re.compile(v,re.I).search661 match=version_re(out or err)662 if match:663 k=match.groupdict()664 conf.env['CC_VERSION']=(k['major'],k['minor'])665 break666 else:667 conf.fatal('Could not determine the XLC version.')668@conf669def get_suncc_version(conf,cc):670 cmd=cc+['-V']671 try:672 out,err=conf.cmd_and_log(cmd,output=0)673 except Errors.WafError:674 conf.fatal('Could not find suncc %r'%cmd)675 version=(out or err)676 version=version.split('\n')[0]677 version_re=re.compile(r'cc:\s+sun\s+(c\+\+|c)\s+(?P<major>\d*)\.(?P<minor>\d*)',re.I).search678 match=version_re(version)679 if match:680 k=match.groupdict()681 conf.env['CC_VERSION']=(k['major'],k['minor'])682 else:683 conf.fatal('Could not determine the suncc version.')684@conf685def add_as_needed(self):686 if self.env.DEST_BINFMT=='elf'and'gcc'in(self.env.CXX_NAME,self.env.CC_NAME):687 self.env.append_unique('LINKFLAGS','--as-needed')688class cfgtask(Task.TaskBase):689 def display(self):690 return''691 def runnable_status(self):692 return Task.RUN_ME693 def uid(self):694 return Utils.SIG_NIL695 def run(self):696 conf=self.conf697 bld=Build.BuildContext(top_dir=conf.srcnode.abspath(),out_dir=conf.bldnode.abspath())698 bld.env=conf.env699 bld.init_dirs()700 bld.in_msg=1701 bld.logger=self.logger702 try:703 bld.check(**self.args)704 except Exception:705 return 1706@conf707def multicheck(self,*k,**kw):708 self.start_msg(kw.get('msg','Executing %d configuration tests'%len(k)))709 class par(object):710 def __init__(self):711 self.keep=False712 self.cache_global=Options.cache_global713 self.nocache=Options.options.nocache714 self.returned_tasks=[]715 self.task_sigs={}716 def total(self):717 return len(tasks)718 def to_log(self,*k,**kw):719 return720 bld=par()721 tasks=[]722 for dct in k:723 x=cfgtask(bld=bld)724 tasks.append(x)725 x.args=dct726 x.bld=bld727 x.conf=self728 x.args=dct729 x.logger=Logs.make_mem_logger(str(id(x)),self.logger)730 def it():731 yield tasks732 while 1:733 yield[]734 p=Runner.Parallel(bld,Options.options.jobs)735 p.biter=it()736 p.start()737 for x in tasks:738 x.logger.memhandler.flush()739 for x in tasks:740 if x.hasrun!=Task.SUCCESS:741 self.end_msg(kw.get('errmsg','no'),color='YELLOW')742 self.fatal(kw.get('fatalmsg',None)or'One of the tests has failed, see the config.log for more information')...

Full Screen

Full Screen

field.py

Source:field.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2'''3Auther: Wood4Date: 2017-09-065Desc: mysqlÁ¬½ÓÆ÷µÄʵÏÖ6'''7import time, logging8class Field(object):9 '''10 table field11 '''12 _count = 013 def __init__(self, **kw):14 self.name = kw.get('name', None)15 self._default = kw.get('default', None)16 self.primary_key = kw.get('primary_key', False)17 self.nullable = kw.get('nullable', False)18 self.updatable = kw.get('updatable', True)19 self.insertable = kw.get('insertable', True)20 self.ddl = kw.get('ddl', '')21 self._order = Field._count22 Field._count = Field._count + 123 @property24 def default(self):25 d = self._default26 return d() if callable(d) else d27 def __str__(self):28 s = ['<%s:%s,%s,default(%s),' % (self.__class__.__name__, self.name, self.ddl, self._default)]29 self.nullable and s.append('N')30 self.updatable and s.append('U')31 self.insertable and s.append('I')32 s.append('>')33 return ''.join(s)34class StringField(Field):35 def __init__(self, **kw):36 if not 'default' in kw:37 kw['default'] = ''38 if not 'ddl' in kw:39 kw['ddl'] = 'varchar(255)'40 super(StringField, self).__init__(**kw)41class IntegerField(Field):42 def __init__(self, **kw):43 if not 'default' in kw:44 kw['default'] = 045 if not 'ddl' in kw:46 kw['ddl'] = 'bigint'47 super(IntegerField, self).__init__(**kw)48class FloatField(Field):49 def __init__(self, **kw):50 if not 'default' in kw:51 kw['default'] = 0.052 if not 'ddl' in kw:53 kw['ddl'] = 'real'54 super(FloatField, self).__init__(**kw)55class BooleanField(Field):56 def __init__(self, **kw):57 if not 'default' in kw:58 kw['default'] = False59 if not 'ddl' in kw:60 kw['ddl'] = 'bool'61 super(BooleanField, self).__init__(**kw)62class TextField(Field):63 def __init__(self, **kw):64 if not 'default' in kw:65 kw['default'] = ''66 if not 'ddl' in kw:67 kw['ddl'] = 'text'68 super(TextField, self).__init__(**kw)69class BlobField(Field):70 def __init__(self, **kw):71 if not 'default' in kw:72 kw['default'] = ''73 if not 'ddl' in kw:74 kw['ddl'] = 'blob'75 super(BlobField, self).__init__(**kw)76class VersionField(Field):77 def __init__(self, name=None):...

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 refurb 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