How to use using method in tox

Best Python code snippet using tox_python

dbbase.py

Source:dbbase.py Github

copy

Full Screen

...40 def findone(self, sid):41 """查询一条"""42 try:43 if self.using:44 return self.instance.objects.using(self.using).get(pk=sid)45 else:46 return self.instance.objects.get(pk=sid)47 except Exception:48 return None49 def findall(self):50 """查询所有"""51 if self.using:52 return self.instance.objects.using(self.using).all()[self.offset:self.limit]53 else:54 return self.instance.objects.all()[self.offset:self.limit]55 def findfilter(self):56 """满足条件"""57 # 包含58 if self.using and self.order_by:59 return self.instance.objects.using(self.using).filter(60 **self.kwargs61 ).order_by(self.order_by)[self.offset:self.limit]62 elif self.using:63 return self.instance.objects.using(self.using).filter(**self.kwargs)[self.offset:self.limit]64 elif self.order_by:65 return self.instance.objects.filter(**self.kwargs).order_by(self.order_by)[self.offset:self.limit]66 else:67 return self.instance.objects.filter(**self.kwargs)[self.offset:self.limit]68 def findexclude(self):69 """不满足条件"""70 # 不包含71 if self.using:72 return self.instance.objects.using(self.using).exclude(**self.kwargs)[self.offset:self.limit]73 else:74 return self.instance.objects.exclude(**self.kwargs)[self.offset:self.limit]75 def findfe(self):76 """精确和模糊查询"""77 # 包含和不包含78 if self.using:79 return self.instance.objects.using(self.using).filter(80 **self.kwargs['filter']81 ).exclude(['exclude'])[self.offset:self.limit]82 else:83 return self.instance.objects.filter(84 **self.kwargs['filter']85 ).exclude(['exclude'])[self.offset:self.limit]86 def db_count(self):87 """统计"""88 if self.using:89 return self.instance.objects.using(self.using).filter(**self.kwargs).count()90 else:91 return self.instance.objects.filter(**self.kwargs).count()92 def sql_raw(self, sql, *args):93 """实例下的SQL查询"""94 if args and self.using:95 return self.instance.objects.using(self.using).raw(sql, args)96 elif args and not self.using:97 return self.instance.objects.raw(sql, args)98 elif not args and self.using:99 return self.instance.objects.using(self.using).raw(sql)100 else:101 return self.instance.objects.raw(sql)102 @staticmethod103 def sql_custom(sql, *args, usings=None):104 from django.db import connections, connection105 """自定义SQL,不介助 实例"""106 if usings:107 cursor = connections[usings].cursor()108 else:109 cursor = connection.cursor()110 if args:111 cursor.execute(sql, args)112 else:113 cursor.execute(sql)114 desc = cursor.description115 return [116 dict(zip([col[0] for col in desc], row))117 for row in cursor.fetchall()118 ]119 def save_db(self):120 """save db"""121 if self.using:122 return self.instance.objects.using(self.using).create(**self.kwargs)123 else:124 return self.instance.objects.create(**self.kwargs)125 def batch_save(self, obj):126 """批量插入"""127 if self.using:128 return self.instance.objects.using(self.using).bulk_create(obj)129 else:130 return self.instance.objects.bulk_create(obj)131 def delete(self, sid):132 """del db"""133 if self.using:134 db_del = self.instance.objects.using(self.using).get(pk=sid)135 db_del.delete()136 else:137 db_del = self.instance.objects.using(self.using).get(pk=sid)138 db_del.delete()139 def update(self, update):140 """更新数据"""141 if self.using:142 return self.instance.objects.using(self.using).filter(**self.kwargs).update(**update)143 else:...

Full Screen

Full Screen

SConscript

Source:SConscript Github

copy

Full Screen

1Import('RTT_ROOT')2Import('rtconfig')3from building import *4cwd = GetCurrentDir()5# add the general drivers.6src = Split("""7""")8if GetDepend(['RT_USING_PIN']):9 src += ['drv_gpio.c']10if GetDepend(['RT_USING_SERIAL']):11 src += ['drv_usart.c']12if GetDepend(['RT_USING_HWTIMER']):13 src += ['drv_hwtimer.c']14if GetDepend(['RT_USING_PWM']):15 src += ['drv_pwm.c']16if GetDepend(['RT_USING_SPI']):17 src += ['drv_spi.c']18if GetDepend(['RT_USING_QSPI']):19 src += ['drv_qspi.c']20if GetDepend(['RT_USING_I2C', 'RT_USING_I2C_BITOPS']):21 if GetDepend('BSP_USING_I2C1') or GetDepend('BSP_USING_I2C2') or GetDepend('BSP_USING_I2C3') or GetDepend('BSP_USING_I2C4'):22 src += ['drv_soft_i2c.c']23if GetDepend(['BSP_USING_ETH', 'RT_USING_LWIP']):24 src += ['drv_eth.c']25if GetDepend(['RT_USING_ADC']):26 src += Glob('drv_adc.c')27if GetDepend(['RT_USING_DAC']):28 src += Glob('drv_dac.c')29if GetDepend(['RT_USING_CAN']):30 src += ['drv_can.c']31if GetDepend(['RT_USING_PM', 'SOC_SERIES_STM32L4']):32 src += ['drv_pm.c']33 src += ['drv_lptim.c']34if GetDepend('BSP_USING_SDRAM'):35 src += ['drv_sdram.c']36if GetDepend('BSP_USING_LCD'):37 src += ['drv_lcd.c']38if GetDepend('BSP_USING_LCD_MIPI'):39 src += ['drv_lcd_mipi.c']40if GetDepend('BSP_USING_ONCHIP_RTC'):41 src += ['drv_rtc.c']42if GetDepend(['BSP_USING_ON_CHIP_FLASH', 'SOC_SERIES_STM32G0']):43 src += ['drv_flash/drv_flash_g0.c']44if GetDepend(['BSP_USING_ON_CHIP_FLASH', 'SOC_SERIES_STM32F0']):45 src += ['drv_flash/drv_flash_f0.c']46if GetDepend(['BSP_USING_ON_CHIP_FLASH', 'SOC_SERIES_STM32F1']):47 src += ['drv_flash/drv_flash_f1.c']48if GetDepend(['BSP_USING_ON_CHIP_FLASH', 'SOC_SERIES_STM32F2']):49 src += ['drv_flash/drv_flash_f2.c']50if GetDepend(['BSP_USING_ON_CHIP_FLASH', 'SOC_SERIES_STM32F4']):51 src += ['drv_flash/drv_flash_f4.c']52if GetDepend(['BSP_USING_ON_CHIP_FLASH', 'SOC_SERIES_STM32F7']):53 src += ['drv_flash/drv_flash_f7.c']54if GetDepend(['BSP_USING_ON_CHIP_FLASH', 'SOC_SERIES_STM32L4']):55 src += ['drv_flash/drv_flash_l4.c']56if GetDepend(['BSP_USING_ON_CHIP_FLASH', 'SOC_SERIES_STM32H7']):57 src += ['drv_flash/drv_flash_h7.c']58if GetDepend('RT_USING_HWCRYPTO'):59 src += ['drv_crypto.c']60if GetDepend(['BSP_USING_WDT']):61 src += ['drv_wdt.c']62if GetDepend(['BSP_USING_SDIO']):63 src += ['drv_sdio.c']64if GetDepend(['BSP_USING_USBD']):65 src += ['drv_usbd.c']66if GetDepend(['BSP_USING_PULSE_ENCODER']):67 src += ['drv_pulse_encoder.c']68if GetDepend(['BSP_USING_USBH']):69 src += ['drv_usbh.c']70src += ['drv_common.c']71path = [cwd]72path += [cwd + '/config']73if GetDepend('BSP_USING_ON_CHIP_FLASH'):74 path += [cwd + '/drv_flash']75group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path)...

Full Screen

Full Screen

brute_force_caesar_cipher.py

Source:brute_force_caesar_cipher.py Github

copy

Full Screen

1def decrypt(message):2 """3 >>> decrypt('TMDETUX PMDVU')4 Decryption using Key #0: TMDETUX PMDVU5 Decryption using Key #1: SLCDSTW OLCUT6 Decryption using Key #2: RKBCRSV NKBTS7 Decryption using Key #3: QJABQRU MJASR8 Decryption using Key #4: PIZAPQT LIZRQ9 Decryption using Key #5: OHYZOPS KHYQP10 Decryption using Key #6: NGXYNOR JGXPO11 Decryption using Key #7: MFWXMNQ IFWON12 Decryption using Key #8: LEVWLMP HEVNM13 Decryption using Key #9: KDUVKLO GDUML14 Decryption using Key #10: JCTUJKN FCTLK15 Decryption using Key #11: IBSTIJM EBSKJ16 Decryption using Key #12: HARSHIL DARJI17 Decryption using Key #13: GZQRGHK CZQIH18 Decryption using Key #14: FYPQFGJ BYPHG19 Decryption using Key #15: EXOPEFI AXOGF20 Decryption using Key #16: DWNODEH ZWNFE21 Decryption using Key #17: CVMNCDG YVMED22 Decryption using Key #18: BULMBCF XULDC23 Decryption using Key #19: ATKLABE WTKCB24 Decryption using Key #20: ZSJKZAD VSJBA25 Decryption using Key #21: YRIJYZC URIAZ26 Decryption using Key #22: XQHIXYB TQHZY27 Decryption using Key #23: WPGHWXA SPGYX28 Decryption using Key #24: VOFGVWZ ROFXW29 Decryption using Key #25: UNEFUVY QNEWV30 """31 LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"32 for key in range(len(LETTERS)):33 translated = ""34 for symbol in message:35 if symbol in LETTERS:36 num = LETTERS.find(symbol)37 num = num - key38 if num < 0:39 num = num + len(LETTERS)40 translated = translated + LETTERS[num]41 else:42 translated = translated + symbol43 print(f"Decryption using Key #{key}: {translated}")44def main():45 message = input("Encrypted message: ")46 message = message.upper()47 decrypt(message)48if __name__ == "__main__":49 import doctest50 doctest.testmod()...

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