Best Python code snippet using fMBT_python
python_魔法方法.py
Source:python_魔法方法.py
...89>>> a+b9058091>>> 92>>> class New_init(int):93 def __add__(self,other):94 return int.__sub__(self,other)95 def __sub__(self,other):96 return int.__add__(self,other)97 98>>> a=New_int(3)99Traceback (most recent call last):100 File "<pyshell#68>", line 1, in <module>101 a=New_int(3)102NameError: name 'New_int' is not defined103>>> a=New_int()104Traceback (most recent call last):105 File "<pyshell#69>", line 1, in <module>106 a=New_int()107NameError: name 'New_int' is not defined108>>> class Newinit(int):109 def __add__(self,other):110 return int.__sub__(self,other)111 def __sub__(self,other):112 return int.__add__(self,other)113 114>>> a=New_int(3)115Traceback (most recent call last):116 File "<pyshell#72>", line 1, in <module>117 a=New_int(3)118NameError: name 'New_int' is not defined119>>> class Newinit(int):120 def __add__(self,other):121 return int.__sub__(self,other)122 def __sub__(self,other):123 return int.__add__(self,other)124 125>>> a=New_int(3)126Traceback (most recent call last):127 File "<pyshell#75>", line 1, in <module>128 a=New_int(3)129NameError: name 'New_int' is not defined130>>> a=Newint(3)131Traceback (most recent call last):132 File "<pyshell#76>", line 1, in <module>133 a=Newint(3)134NameError: name 'Newint' is not defined135>>> class New_int(int):136 def __add__(self,other):137 return int.__sub__(self,other)138 def __sub__(self,other):139 return int.__add__(self,other)140 141>>> a=New_int(3)142>>> b=New_int(5)143>>> a+b144-2145>>> a-b1468147>>> 148>>> class Try_int(int)149SyntaxError: invalid syntax150>>> class Try_int(int):151 def __add__(self,other):152 return self + other153 def __sub__(self,other):154 return self - other155 156>>> a=Try_int(3)157>>> b=Try_int(4)158>>> a+b159Traceback (most recent call last):160 File "<pyshell#93>", line 1, in <module>161 a+b162 File "<pyshell#90>", line 3, in __add__163 return self + other164 File "<pyshell#90>", line 3, in __add__165 return self + other166 File "<pyshell#90>", line 3, in __add__167 return self + other168 File "<pyshell#90>", line 3, in __add__169 return self + other170 File "<pyshell#90>", line 3, in __add__171 return self + other172 File "<pyshell#90>", line 3, in __add__173 return self + other174 File "<pyshell#90>", line 3, in __add__175 return self + other176 File "<pyshell#90>", line 3, in __add__177 return self + other178 File "<pyshell#90>", line 3, in __add__179 return self + other180 File "<pyshell#90>", line 3, in __add__181 return self + other182 File "<pyshell#90>", line 3, in __add__183 return self + other184 File "<pyshell#90>", line 3, in __add__185 return self + other186 File "<pyshell#90>", line 3, in __add__187 return self + other188 File "<pyshell#90>", line 3, in __add__189 return self + other190 File "<pyshell#90>", line 3, in __add__191 return self + other192 File "<pyshell#90>", line 3, in __add__193 return self + other194 File "<pyshell#90>", line 3, in __add__195 return self + other196 File "<pyshell#90>", line 3, in __add__197 return self + other198 File "<pyshell#90>", line 3, in __add__199 return self + other200 File "<pyshell#90>", line 3, in __add__201 return self + other202 File "<pyshell#90>", line 3, in __add__203 return self + other204 File "<pyshell#90>", line 3, in __add__205 return self + other206 File "<pyshell#90>", line 3, in __add__207 return self + other208 File "<pyshell#90>", line 3, in __add__209 return self + other210 File "<pyshell#90>", line 3, in __add__211 return self + other212 File "<pyshell#90>", line 3, in __add__213 return self + other214 File "<pyshell#90>", line 3, in __add__215 return self + other216 File "<pyshell#90>", line 3, in __add__217 return self + other218 File "<pyshell#90>", line 3, in __add__219 return self + other220 File "<pyshell#90>", line 3, in __add__221 return self + other222 File "<pyshell#90>", line 3, in __add__223 return self + other224 File "<pyshell#90>", line 3, in __add__225 return self + other226 File "<pyshell#90>", line 3, in __add__227 return self + other228 File "<pyshell#90>", line 3, in __add__229 return self + other230 File "<pyshell#90>", line 3, in __add__231 return self + other232 File "<pyshell#90>", line 3, in __add__233 return self + other234 File "<pyshell#90>", line 3, in __add__235 return self + other236 File "<pyshell#90>", line 3, in __add__237 return self + other238 File "<pyshell#90>", line 3, in __add__239 return self + other240 File "<pyshell#90>", line 3, in __add__241 return self + other242 File "<pyshell#90>", line 3, in __add__243 return self + other244 File "<pyshell#90>", line 3, in __add__245 return self + other246 File "<pyshell#90>", line 3, in __add__247 return self + other248 File "<pyshell#90>", line 3, in __add__249 return self + other250 File "<pyshell#90>", line 3, in __add__251 return self + other252 File "<pyshell#90>", line 3, in __add__253 return self + other254 File "<pyshell#90>", line 3, in __add__255 return self + other256 File "<pyshell#90>", line 3, in __add__257 return self + other258 File "<pyshell#90>", line 3, in __add__259 return self + other260 File "<pyshell#90>", line 3, in __add__261 return self + other262 File "<pyshell#90>", line 3, in __add__263 return self + other264 File "<pyshell#90>", line 3, in __add__265 return self + other266 File "<pyshell#90>", line 3, in __add__267 return self + other268 File "<pyshell#90>", line 3, in __add__269 return self + other270 File "<pyshell#90>", line 3, in __add__271 return self + other272 File "<pyshell#90>", line 3, in __add__273 return self + other274 File "<pyshell#90>", line 3, in __add__275 return self + other276 File "<pyshell#90>", line 3, in __add__277 return self + other278 File "<pyshell#90>", line 3, in __add__279 return self + other280 File "<pyshell#90>", line 3, in __add__281 return self + other282 File "<pyshell#90>", line 3, in __add__283 return self + other284 File "<pyshell#90>", line 3, in __add__285 return self + other286 File "<pyshell#90>", line 3, in __add__287 return self + other288 File "<pyshell#90>", line 3, in __add__289 return self + other290 File "<pyshell#90>", line 3, in __add__291 return self + other292 File "<pyshell#90>", line 3, in __add__293 return self + other294 File "<pyshell#90>", line 3, in __add__295 return self + other296 File "<pyshell#90>", line 3, in __add__297 return self + other298 File "<pyshell#90>", line 3, in __add__299 return self + other300 File "<pyshell#90>", line 3, in __add__301 return self + other302 File "<pyshell#90>", line 3, in __add__303 return self + other304 File "<pyshell#90>", line 3, in __add__305 return self + other306 File "<pyshell#90>", line 3, in __add__307 return self + other308 File "<pyshell#90>", line 3, in __add__309 return self + other310 File "<pyshell#90>", line 3, in __add__311 return self + other312 File "<pyshell#90>", line 3, in __add__313 return self + other314 File "<pyshell#90>", line 3, in __add__315 return self + other316 File "<pyshell#90>", line 3, in __add__317 return self + other318 File "<pyshell#90>", line 3, in __add__319 return self + other320 File "<pyshell#90>", line 3, in __add__321 return self + other322 File "<pyshell#90>", line 3, in __add__323 return self + other324 File "<pyshell#90>", line 3, in __add__325 return self + other326 File "<pyshell#90>", line 3, in __add__327 return self + other328 File "<pyshell#90>", line 3, in __add__329 return self + other330 File "<pyshell#90>", line 3, in __add__331 return self + other332 File "<pyshell#90>", line 3, in __add__333 return self + other334 File "<pyshell#90>", line 3, in __add__335 return self + other336 File "<pyshell#90>", line 3, in __add__337 return self + other338 File "<pyshell#90>", line 3, in __add__339 return self + other340 File "<pyshell#90>", line 3, in __add__341 return self + other342 File "<pyshell#90>", line 3, in __add__343 return self + other344 File "<pyshell#90>", line 3, in __add__345 return self + other346 File "<pyshell#90>", line 3, in __add__347 return self + other348 File "<pyshell#90>", line 3, in __add__349 return self + other350 File "<pyshell#90>", line 3, in __add__351 return self + other352 File "<pyshell#90>", line 3, in __add__353 return self + other354 File "<pyshell#90>", line 3, in __add__355 return self + other356 File "<pyshell#90>", line 3, in __add__357 return self + other358 File "<pyshell#90>", line 3, in __add__359 return self + other360 File "<pyshell#90>", line 3, in __add__361 return self + other362 File "<pyshell#90>", line 3, in __add__363 return self + other364 File "<pyshell#90>", line 3, in __add__365 return self + other366 File "<pyshell#90>", line 3, in __add__367 return self + other368 File "<pyshell#90>", line 3, in __add__369 return self + other370 File "<pyshell#90>", line 3, in __add__371 return self + other372 File "<pyshell#90>", line 3, in __add__373 return self + other374 File "<pyshell#90>", line 3, in __add__375 return self + other376 File "<pyshell#90>", line 3, in __add__377 return self + other378 File "<pyshell#90>", line 3, in __add__379 return self + other380 File "<pyshell#90>", line 3, in __add__381 return self + other382 File "<pyshell#90>", line 3, in __add__383 return self + other384 File "<pyshell#90>", line 3, in __add__385 return self + other386 File "<pyshell#90>", line 3, in __add__387 return self + other388 File "<pyshell#90>", line 3, in __add__389 return self + other390 File "<pyshell#90>", line 3, in __add__391 return self + other392 File "<pyshell#90>", line 3, in __add__393 return self + other394 File "<pyshell#90>", line 3, in __add__395 return self + other396 File "<pyshell#90>", line 3, in __add__397 return self + other398 File "<pyshell#90>", line 3, in __add__399 return self + other400 File "<pyshell#90>", line 3, in __add__401 return self + other402 File "<pyshell#90>", line 3, in __add__403 return self + other404 File "<pyshell#90>", line 3, in __add__405 return self + other406 File "<pyshell#90>", line 3, in __add__407 return self + other408 File "<pyshell#90>", line 3, in __add__409 return self + other410 File "<pyshell#90>", line 3, in __add__411 return self + other412 File "<pyshell#90>", line 3, in __add__413 return self + other414 File "<pyshell#90>", line 3, in __add__415 return self + other416 File "<pyshell#90>", line 3, in __add__417 return self + other418 File "<pyshell#90>", line 3, in __add__419 return self + other420 File "<pyshell#90>", line 3, in __add__421 return self + other422 File "<pyshell#90>", line 3, in __add__423 return self + other424 File "<pyshell#90>", line 3, in __add__425 return self + other426 File "<pyshell#90>", line 3, in __add__427 return self + other428 File "<pyshell#90>", line 3, in __add__429 return self + other430 File "<pyshell#90>", line 3, in __add__431 return self + other432 File "<pyshell#90>", line 3, in __add__433 return self + other434 File "<pyshell#90>", line 3, in __add__435 return self + other436 File "<pyshell#90>", line 3, in __add__437 return self + other438 File "<pyshell#90>", line 3, in __add__439 return self + other440 File "<pyshell#90>", line 3, in __add__441 return self + other442 File "<pyshell#90>", line 3, in __add__443 return self + other444 File "<pyshell#90>", line 3, in __add__445 return self + other446 File "<pyshell#90>", line 3, in __add__447 return self + other448 File "<pyshell#90>", line 3, in __add__449 return self + other450 File "<pyshell#90>", line 3, in __add__451 return self + other452 File "<pyshell#90>", line 3, in __add__453 return self + other454 File "<pyshell#90>", line 3, in __add__455 return self + other456 File "<pyshell#90>", line 3, in __add__457 return self + other458 File "<pyshell#90>", line 3, in __add__459 return self + other460 File "<pyshell#90>", line 3, in __add__461 return self + other462 File "<pyshell#90>", line 3, in __add__463 return self + other464 File "<pyshell#90>", line 3, in __add__465 return self + other466 File "<pyshell#90>", line 3, in __add__467 return self + other468 File "<pyshell#90>", line 3, in __add__469 return self + other470 File "<pyshell#90>", line 3, in __add__471 return self + other472 File "<pyshell#90>", line 3, in __add__473 return self + other474 File "<pyshell#90>", line 3, in __add__475 return self + other476 File "<pyshell#90>", line 3, in __add__477 return self + other478 File "<pyshell#90>", line 3, in __add__479 return self + other480 File "<pyshell#90>", line 3, in __add__481 return self + other482 File "<pyshell#90>", line 3, in __add__483 return self + other484 File "<pyshell#90>", line 3, in __add__485 return self + other486 File "<pyshell#90>", line 3, in __add__487 return self + other488 File "<pyshell#90>", line 3, in __add__489 return self + other490 File "<pyshell#90>", line 3, in __add__491 return self + other492 File "<pyshell#90>", line 3, in __add__493 return self + other494 File "<pyshell#90>", line 3, in __add__495 return self + other496 File "<pyshell#90>", line 3, in __add__497 return self + other498 File "<pyshell#90>", line 3, in __add__499 return self + other500 File "<pyshell#90>", line 3, in __add__501 return self + other502 File "<pyshell#90>", line 3, in __add__503 return self + other504 File "<pyshell#90>", line 3, in __add__505 return self + other506 File "<pyshell#90>", line 3, in __add__507 return self + other508 File "<pyshell#90>", line 3, in __add__509 return self + other510 File "<pyshell#90>", line 3, in __add__511 return self + other512 File "<pyshell#90>", line 3, in __add__513 return self + other514 File "<pyshell#90>", line 3, in __add__515 return self + other516 File "<pyshell#90>", line 3, in __add__517 return self + other518 File "<pyshell#90>", line 3, in __add__519 return self + other520 File "<pyshell#90>", line 3, in __add__521 return self + other522 File "<pyshell#90>", line 3, in __add__523 return self + other524 File "<pyshell#90>", line 3, in __add__525 return self + other526 File "<pyshell#90>", line 3, in __add__527 return self + other528 File "<pyshell#90>", line 3, in __add__529 return self + other530 File "<pyshell#90>", line 3, in __add__531 return self + other532 File "<pyshell#90>", line 3, in __add__533 return self + other534 File "<pyshell#90>", line 3, in __add__535 return self + other536 File "<pyshell#90>", line 3, in __add__537 return self + other538 File "<pyshell#90>", line 3, in __add__539 return self + other540 File "<pyshell#90>", line 3, in __add__541 return self + other542 File "<pyshell#90>", line 3, in __add__543 return self + other544 File "<pyshell#90>", line 3, in __add__545 return self + other546 File "<pyshell#90>", line 3, in __add__547 return self + other548 File "<pyshell#90>", line 3, in __add__549 return self + other550 File "<pyshell#90>", line 3, in __add__551 return self + other552 File "<pyshell#90>", line 3, in __add__553 return self + other554 File "<pyshell#90>", line 3, in __add__555 return self + other556 File "<pyshell#90>", line 3, in __add__557 return self + other558 File "<pyshell#90>", line 3, in __add__559 return self + other560 File "<pyshell#90>", line 3, in __add__561 return self + other562 File "<pyshell#90>", line 3, in __add__563 return self + other564 File "<pyshell#90>", line 3, in __add__565 return self + other566 File "<pyshell#90>", line 3, in __add__567 return self + other568 File "<pyshell#90>", line 3, in __add__569 return self + other570 File "<pyshell#90>", line 3, in __add__571 return self + other572 File "<pyshell#90>", line 3, in __add__573 return self + other574 File "<pyshell#90>", line 3, in __add__575 return self + other576 File "<pyshell#90>", line 3, in __add__577 return self + other578 File "<pyshell#90>", line 3, in __add__579 return self + other580 File "<pyshell#90>", line 3, in __add__581 return self + other582 File "<pyshell#90>", line 3, in __add__583 return self + other584 File "<pyshell#90>", line 3, in __add__585 return self + other586 File "<pyshell#90>", line 3, in __add__587 return self + other588 File "<pyshell#90>", line 3, in __add__589 return self + other590 File "<pyshell#90>", line 3, in __add__591 return self + other592 File "<pyshell#90>", line 3, in __add__593 return self + other594 File "<pyshell#90>", line 3, in __add__595 return self + other596 File "<pyshell#90>", line 3, in __add__597 return self + other598 File "<pyshell#90>", line 3, in __add__599 return self + other600 File "<pyshell#90>", line 3, in __add__601 return self + other602 File "<pyshell#90>", line 3, in __add__603 return self + other604 File "<pyshell#90>", line 3, in __add__605 return self + other606 File "<pyshell#90>", line 3, in __add__607 return self + other608 File "<pyshell#90>", line 3, in __add__609 return self + other610 File "<pyshell#90>", line 3, in __add__611 return self + other612 File "<pyshell#90>", line 3, in __add__613 return self + other614 File "<pyshell#90>", line 3, in __add__615 return self + other616 File "<pyshell#90>", line 3, in __add__617 return self + other618 File "<pyshell#90>", line 3, in __add__619 return self + other620 File "<pyshell#90>", line 3, in __add__621 return self + other622 File "<pyshell#90>", line 3, in __add__623 return self + other624 File "<pyshell#90>", line 3, in __add__625 return self + other626 File "<pyshell#90>", line 3, in __add__627 return self + other628 File "<pyshell#90>", line 3, in __add__629 return self + other630 File "<pyshell#90>", line 3, in __add__631 return self + other632 File "<pyshell#90>", line 3, in __add__633 return self + other634 File "<pyshell#90>", line 3, in __add__635 return self + other636 File "<pyshell#90>", line 3, in __add__637 return self + other638 File "<pyshell#90>", line 3, in __add__639 return self + other640 File "<pyshell#90>", line 3, in __add__641 return self + other642 File "<pyshell#90>", line 3, in __add__643 return self + other644 File "<pyshell#90>", line 3, in __add__645 return self + other646 File "<pyshell#90>", line 3, in __add__647 return self + other648 File "<pyshell#90>", line 3, in __add__649 return self + other650 File "<pyshell#90>", line 3, in __add__651 return self + other652 File "<pyshell#90>", line 3, in __add__653 return self + other654 File "<pyshell#90>", line 3, in __add__655 return self + other656 File "<pyshell#90>", line 3, in __add__657 return self + other658 File "<pyshell#90>", line 3, in __add__659 return self + other660 File "<pyshell#90>", line 3, in __add__661 return self + other662 File "<pyshell#90>", line 3, in __add__663 return self + other664 File "<pyshell#90>", line 3, in __add__665 return self + other666 File "<pyshell#90>", line 3, in __add__667 return self + other668 File "<pyshell#90>", line 3, in __add__669 return self + other670 File "<pyshell#90>", line 3, in __add__671 return self + other672 File "<pyshell#90>", line 3, in __add__673 return self + other674 File "<pyshell#90>", line 3, in __add__675 return self + other676 File "<pyshell#90>", line 3, in __add__677 return self + other678 File "<pyshell#90>", line 3, in __add__679 return self + other680 File "<pyshell#90>", line 3, in __add__681 return self + other682 File "<pyshell#90>", line 3, in __add__683 return self + other684 File "<pyshell#90>", line 3, in __add__685 return self + other686 File "<pyshell#90>", line 3, in __add__687 return self + other688 File "<pyshell#90>", line 3, in __add__689 return self + other690 File "<pyshell#90>", line 3, in __add__691 return self + other692 File "<pyshell#90>", line 3, in __add__693 return self + other694 File "<pyshell#90>", line 3, in __add__695 return self + other696 File "<pyshell#90>", line 3, in __add__697 return self + other698 File "<pyshell#90>", line 3, in __add__699 return self + other700 File "<pyshell#90>", line 3, in __add__701 return self + other702 File "<pyshell#90>", line 3, in __add__703 return self + other704 File "<pyshell#90>", line 3, in __add__705 return self + other706 File "<pyshell#90>", line 3, in __add__707 return self + other708 File "<pyshell#90>", line 3, in __add__709 return self + other710 File "<pyshell#90>", line 3, in __add__711 return self + other712 File "<pyshell#90>", line 3, in __add__713 return self + other714 File "<pyshell#90>", line 3, in __add__715 return self + other716 File "<pyshell#90>", line 3, in __add__717 return self + other718 File "<pyshell#90>", line 3, in __add__719 return self + other720 File "<pyshell#90>", line 3, in __add__721 return self + other722 File "<pyshell#90>", line 3, in __add__723 return self + other724 File "<pyshell#90>", line 3, in __add__725 return self + other726 File "<pyshell#90>", line 3, in __add__727 return self + other728 File "<pyshell#90>", line 3, in __add__729 return self + other730 File "<pyshell#90>", line 3, in __add__731 return self + other732 File "<pyshell#90>", line 3, in __add__733 return self + other734 File "<pyshell#90>", line 3, in __add__735 return self + other736 File "<pyshell#90>", line 3, in __add__737 return self + other738 File "<pyshell#90>", line 3, in __add__739 return self + other740 File "<pyshell#90>", line 3, in __add__741 return self + other742 File "<pyshell#90>", line 3, in __add__743 return self + other744 File "<pyshell#90>", line 3, in __add__745 return self + other746 File "<pyshell#90>", line 3, in __add__747 return self + other748 File "<pyshell#90>", line 3, in __add__749 return self + other750 File "<pyshell#90>", line 3, in __add__751 return self + other752 File "<pyshell#90>", line 3, in __add__753 return self + other754 File "<pyshell#90>", line 3, in __add__755 return self + other756 File "<pyshell#90>", line 3, in __add__757 return self + other758 File "<pyshell#90>", line 3, in __add__759 return self + other760 File "<pyshell#90>", line 3, in __add__761 return self + other762 File "<pyshell#90>", line 3, in __add__763 return self + other764 File "<pyshell#90>", line 3, in __add__765 return self + other766 File "<pyshell#90>", line 3, in __add__767 return self + other768 File "<pyshell#90>", line 3, in __add__769 return self + other770 File "<pyshell#90>", line 3, in __add__771 return self + other772 File "<pyshell#90>", line 3, in __add__773 return self + other774 File "<pyshell#90>", line 3, in __add__775 return self + other776 File "<pyshell#90>", line 3, in __add__777 return self + other778 File "<pyshell#90>", line 3, in __add__779 return self + other780 File "<pyshell#90>", line 3, in __add__781 return self + other782 File "<pyshell#90>", line 3, in __add__783 return self + other784 File "<pyshell#90>", line 3, in __add__785 return self + other786 File "<pyshell#90>", line 3, in __add__787 return self + other788 File "<pyshell#90>", line 3, in __add__789 return self + other790 File "<pyshell#90>", line 3, in __add__791 return self + other792 File "<pyshell#90>", line 3, in __add__793 return self + other794 File "<pyshell#90>", line 3, in __add__795 return self + other796 File "<pyshell#90>", line 3, in __add__797 return self + other798 File "<pyshell#90>", line 3, in __add__799 return self + other800 File "<pyshell#90>", line 3, in __add__801 return self + other802 File "<pyshell#90>", line 3, in __add__803 return self + other804 File "<pyshell#90>", line 3, in __add__805 return self + other806 File "<pyshell#90>", line 3, in __add__807 return self + other808 File "<pyshell#90>", line 3, in __add__809 return self + other810 File "<pyshell#90>", line 3, in __add__811 return self + other812 File "<pyshell#90>", line 3, in __add__813 return self + other814 File "<pyshell#90>", line 3, in __add__815 return self + other816 File "<pyshell#90>", line 3, in __add__817 return self + other818 File "<pyshell#90>", line 3, in __add__819 return self + other820 File "<pyshell#90>", line 3, in __add__821 return self + other822 File "<pyshell#90>", line 3, in __add__823 return self + other824RecursionError: maximum recursion depth exceeded825>>> class Try_int(int):826 def __add__(self,other):827 return int(self) + int(other)828 def __sub__(self,other):829 return int(self) - int(other)830 831>>> a=Try_int(3)832>>> b=Try_int(5)833>>> b+a8348835>>> 836>>> #éæ³æ¹æ³837>>> class int(int):838 def __add__(self,other):839 return int.__sub__(self,other)840 841>>> a=int('5')842>>> a8435844>>> b = int(3)845>>> a+b8462847>>> 848=============================== RESTART: Shell ===============================849>>> class Nint(int):850 def __radd__(self,other):851 return int.sub__(self,other)852 ...
test_multiple_ip_ranges.py
Source:test_multiple_ip_ranges.py
...163 ip2 = self.increment_cidr()164 test_nw = ip2.network165 ip = IPAddress(test_nw)166 #Add IP range(5 IPs) in the new CIDR167 test_gateway = ip.__add__(1)168 test_startIp = ip.__add__(3)169 test_endIp = ip.__add__(10)170 test_startIp2= ip.__add__(11)171 test_endIp2 = ip.__add__(15)172 #Populating services with new IP range173 self.services["vlan_ip_range"]["startip"] = test_startIp174 self.services["vlan_ip_range"]["endip"] = test_endIp175 self.services["vlan_ip_range"]["gateway"] = test_gateway176 self.services["vlan_ip_range"]["netmask"] = self.netmask177 self.services["vlan_ip_range"]["zoneid"] = self.zone.id178 self.services["vlan_ip_range"]["podid"] = self.pod.id179 #create new vlan ip range180 new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])181 self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))182 self.cleanup.append(new_vlan)183 new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id)184 #Compare list output with configured values185 self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"])186 #Add few more ips in the same CIDR187 self.services["vlan_ip_range"]["startip"] = test_startIp2188 self.services["vlan_ip_range"]["endip"] = test_endIp2189 new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])190 self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp2,test_endIp2))191 self.cleanup.append(new_vlan2)192 #list new vlan ip range193 new_vlan2_res = new_vlan2.list(self.apiclient,id=new_vlan2.vlan.id)194 #Compare list output with configured values195 self.verify_vlan_range(new_vlan2_res,self.services["vlan_ip_range"])196 return197 @attr(tags=["advanced_sg", "sg"])198 def test_02_add_ip_diff_cidr(self):199 """Test add ip range in a new cidr200 Steps:201 1.Get public vlan range (guest cidr) from the setup202 2.Add IP range to a new cidr203 """204 #call increment_cidr function to get exiting cidr from the setup and increment it205 ip2 = self.increment_cidr()206 test_nw = ip2.network207 ip = IPAddress(test_nw)208 #Add IP range(5 IPs) in the new CIDR209 test_gateway = ip.__add__(1)210 test_startIp = ip.__add__(3)211 test_endIp = ip.__add__(10)212 #Populating services with new IP range213 self.services["vlan_ip_range"]["startip"] = test_startIp214 self.services["vlan_ip_range"]["endip"] = test_endIp215 self.services["vlan_ip_range"]["gateway"] = test_gateway216 self.services["vlan_ip_range"]["netmask"] = self.netmask217 self.services["vlan_ip_range"]["zoneid"] = self.zone.id218 self.services["vlan_ip_range"]["podid"] = self.pod.id219 #create new vlan ip range220 new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])221 self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))222 self.cleanup.append(new_vlan)223 new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id)224 #Compare list output with configured values225 self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"])226 return227 @attr(tags=["advanced_sg", "sg"])228 def test_03_del_ip_range(self):229 """Test delete ip range230 Steps:231 1.Add ip range in same/new cidr232 2.delete the ip range added at step1233 3.Verify the ip range deletion using list APIs234 """235 #call increment_cidr function to get exiting cidr from the setup and increment it236 ip2 = self.increment_cidr()237 test_nw = ip2.network238 ip = IPAddress(test_nw)239 #Add IP range(5 IPs) in the new CIDR240 test_gateway = ip.__add__(1)241 test_startIp = ip.__add__(3)242 test_endIp = ip.__add__(10)243 #Populating services with new IP range244 self.services["vlan_ip_range"]["startip"] = test_startIp245 self.services["vlan_ip_range"]["endip"] = test_endIp246 self.services["vlan_ip_range"]["gateway"] = test_gateway247 self.services["vlan_ip_range"]["netmask"] = self.netmask248 self.services["vlan_ip_range"]["zoneid"] = self.zone.id249 self.services["vlan_ip_range"]["podid"] = self.pod.id250 #create new vlan ip range251 new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])252 self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))253 new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id)254 #Compare list output with configured values255 self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"])256 #Delete the above IP range257 new_vlan.delete(self.apiclient)258 #listing vlan ip ranges with the id should through exception , if not mark the test case as failed259 try:260 new_vlan.list(self.apiclient, id=new_vlan.vlan.id)261 except cloudstackAPIException as cs:262 self.debug(cs.errorMsg)263 self.assertTrue(cs.errorMsg.find("entity does not exist")>0, msg="Failed to delete IP range")264 return265 @attr(tags=["advanced_sg", "sg"])266 def test_04_add_noncontiguous_ip_range(self):267 """Test adding non-contiguous ip range in existing cidr268 1.Add ip range in new cidr269 1.Add non-contigous ip range in cidr added at step1270 2.Verify the ip range using list APIs271 """272 #call increment_cidr function to get exiting cidr from the setup and increment it273 ip2 = self.increment_cidr()274 test_nw = ip2.network275 ip = IPAddress(test_nw)276 #Add IP range(5 IPs) in the new CIDR277 test_gateway = ip.__add__(1)278 test_startIp = ip.__add__(50)279 test_endIp = ip.__add__(60)280 #Populating services with new IP range281 self.services["vlan_ip_range"]["startip"] = test_startIp282 self.services["vlan_ip_range"]["endip"] = test_endIp283 self.services["vlan_ip_range"]["gateway"] = test_gateway284 self.services["vlan_ip_range"]["netmask"] = self.netmask285 self.services["vlan_ip_range"]["zoneid"] = self.zone.id286 self.services["vlan_ip_range"]["podid"] = self.pod.id287 #create new vlan ip range288 new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])289 self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))290 self.cleanup.append(new_vlan)291 new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id)292 #Compare list output with configured values293 self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"])294 #Add non-contiguous ip range in exiting cidr295 test_startIp2 = ip.__add__(10)296 test_endIp2 = ip.__add__(20)297 #Populating services with new IP range298 self.services["vlan_ip_range"]["startip"] = test_startIp2299 self.services["vlan_ip_range"]["endip"] = test_endIp2300 #create new vlan ip range301 new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])302 self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))303 self.cleanup.append(new_vlan)304 new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id)305 #Compare list output with configured values306 self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"])307 return308 @attr(tags=["advanced_sg", "sg"])309 def test_05_add_overlapped_ip_range(self):310 """Test adding overlapped ip range in existing cidr311 1.Add ip range in new cidr e.g:10.147.40.10-10.147.40.100312 2.Add ip range overlapped with the ip range in step1 e.g.10.147.40.90-150313 """314 #call increment_cidr function to get exiting cidr from the setup and increment it315 ip2 = self.increment_cidr()316 test_nw = ip2.network317 ip = IPAddress(test_nw)318 #Add IP range in the new CIDR319 test_gateway = ip.__add__(1)320 test_startIp = ip.__add__(10)321 test_endIp = ip.__add__(100)322 test_startIp2 = ip.__add__(90)323 test_endIp2 = ip.__add__(150)324 #Populating services with new IP range325 self.services["vlan_ip_range"]["startip"] = test_startIp326 self.services["vlan_ip_range"]["endip"] = test_endIp327 self.services["vlan_ip_range"]["gateway"] = test_gateway328 self.services["vlan_ip_range"]["netmask"] = self.netmask329 self.services["vlan_ip_range"]["zoneid"] = self.zone.id330 self.services["vlan_ip_range"]["podid"] = self.pod.id331 #create new vlan ip range332 new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])333 self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))334 self.cleanup.append(new_vlan)335 new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id)336 #Compare list output with configured values337 self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"])338 #Add overlapped ip range339 #Populating services with new IP range340 self.services["vlan_ip_range"]["startip"] = test_startIp2341 self.services["vlan_ip_range"]["endip"] = test_endIp2342 #Try to create ip range overlapped with exiting ip range343 try:344 new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])345 except cloudstackAPIException as cs:346 self.debug(cs.errorMsg)347 self.assertTrue(cs.errorMsg.find("already has IPs that overlap with the new range")>0, msg="Fail:CS allowed adding overlapped ip ranges in guest cidr")348 return349 #Test will reach here if there is a bug in overlap ip range checking350 self.cleanup.append(new_vlan2)351 self.fail("CS should not accept overlapped ip ranges in guest traffic, but it allowed")352 return353 @attr(tags=["advanced_sg", "sg"])354 def test_06_add_ip_range_overlapped_with_two_ranges(self):355 """Test adding overlapped ip range in existing cidr356 1.Add ip range in new cidr e.g:10.147.40.2-10.147.40.10357 2.Add another ip range in the same cidr e.g:10.147.40.20-10.147.40.30358 2.Add ip range overlapped with both the ip ranges e.g.10.147.40.10-20359 """360 #call increment_cidr function to get exiting cidr from the setup and increment it361 ip2 = self.increment_cidr()362 test_nw = ip2.network363 ip = IPAddress(test_nw)364 #Add IP range in the new CIDR365 test_gateway = ip.__add__(1)366 test_startIp = ip.__add__(2)367 test_endIp = ip.__add__(10)368 test_startIp2 = ip.__add__(20)369 test_endIp2 = ip.__add__(30)370 test_startIp3 = ip.__add__(10)371 test_endIp3 = ip.__add__(20)372 #Populating services with new IP range373 self.services["vlan_ip_range"]["startip"] = test_startIp374 self.services["vlan_ip_range"]["endip"] = test_endIp375 self.services["vlan_ip_range"]["gateway"] = test_gateway376 self.services["vlan_ip_range"]["netmask"] = self.netmask377 self.services["vlan_ip_range"]["zoneid"] = self.zone.id378 self.services["vlan_ip_range"]["podid"] = self.pod.id379 #create new vlan ip range380 new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])381 self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))382 self.cleanup.append(new_vlan)383 new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id)384 #Compare list output with configured values385 self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"])386 #Add 2nd IP range in the same CIDR387 self.services["vlan_ip_range"]["startip"] = test_startIp2388 self.services["vlan_ip_range"]["endip"] = test_endIp2389 new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])390 self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp2,test_endIp2))391 self.cleanup.append(new_vlan2)392 new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id)393 #Compare list output with configured values394 self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"])395 #Add ip range which will overlap with two existing ip ranges in the same CIDR396 #Populating services with new IP range397 self.services["vlan_ip_range"]["startip"] = test_startIp3398 self.services["vlan_ip_range"]["endip"] = test_endIp3399 #Try to create ip range overlapped with exiting ip range400 try:401 new_vlan3 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])402 except cloudstackAPIException as cs:403 self.debug(cs.errorMsg)404 self.assertTrue(cs.errorMsg.find("already has IPs that overlap with the new range")>0, msg="Fail:CS allowed adding overlapped ip ranges in guest cidr")405 return406 #Test will reach here if there is a bug in overlap ip range checking407 self.cleanup.append(new_vlan3)408 self.fail("CS should not accept overlapped ip ranges in guest traffic, but it allowed")409 return410 @attr(tags=["advanced_sg", "sg"])411 def test_07_add_iprange_superset(self):412 """Test adding ip range superset to existing CIDR413 1.Add IP range in new CIDR414 2.Try to add ip range superset to CIDR added in step1415 """416 #call increment_cidr function to get exiting cidr from the setup and increment it417 ip2 = self.increment_cidr()418 test_nw = ip2.network419 ip = IPAddress(test_nw)420 #Add IP range in the new CIDR421 test_gateway = ip.__add__(1)422 test_startIp = ip.__add__(2)423 test_endIp = ip.__add__(10)424 test_startIp2 = ip.__add__(20)425 test_endIp2 = ip.__add__(30)426 #Populating services with new IP range427 self.services["vlan_ip_range"]["startip"] = test_startIp428 self.services["vlan_ip_range"]["endip"] = test_endIp429 self.services["vlan_ip_range"]["gateway"] = test_gateway430 self.services["vlan_ip_range"]["netmask"] = self.netmask431 self.services["vlan_ip_range"]["zoneid"] = self.zone.id432 self.services["vlan_ip_range"]["podid"] = self.pod.id433 #create new vlan ip range434 new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])435 self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))436 self.cleanup.append(new_vlan)437 new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id)438 #Compare list output with configured values439 self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"])440 #Add ip range superset to the existing CIDR441 #Following code finds the netmask superset to existing CIDR442 cidr = ip2.cidr443 mask_len = 2**(32-cidr.prefixlen)444 netmask = IPAddress(self.netmask)445 superset = netmask.__isub__(mask_len)446 #Add this superset netmask to services447 self.services["vlan_ip_range"]["netmask"] = superset448 self.services["vlan_ip_range"]["startip"] = test_startIp2449 self.services["vlan_ip_range"]["endip"] = test_endIp2450 try:451 new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])452 except cloudstackAPIException as cs:453 self.debug(cs.errorMsg)454 self.assertTrue(cs.errorMsg.find("new subnet is a super set of the existing subnet")>0, msg="Fail: CS allowed adding ip range superset to existing CIDR")455 return456 #Test will reach here if there is a bug in allowing superset ip range457 self.cleanup.append(new_vlan2)458 self.fail("CS should not allow adding ip range superset to existing CIDR")459 return460 @attr(tags=["advanced_sg", "sg"])461 def test_08_add_iprange_subset(self):462 """Test adding ip range subset to existing CIDR463 1.Add IP range in new CIDR464 2.Try to add ip range subset to CIDR added in step1465 """466 #call increment_cidr function to get exiting cidr from the setup and increment it467 ip2 = self.increment_cidr()468 test_nw = ip2.network469 ip = IPAddress(test_nw)470 #Add IP range in the new CIDR471 test_gateway = ip.__add__(1)472 test_startIp = ip.__add__(2)473 test_endIp = ip.__add__(10)474 test_startIp2 = ip.__add__(20)475 test_endIp2 = ip.__add__(30)476 #Populating services with new IP range477 self.services["vlan_ip_range"]["startip"] = test_startIp478 self.services["vlan_ip_range"]["endip"] = test_endIp479 self.services["vlan_ip_range"]["gateway"] = test_gateway480 self.services["vlan_ip_range"]["netmask"] = self.netmask481 self.services["vlan_ip_range"]["zoneid"] = self.zone.id482 self.services["vlan_ip_range"]["podid"] = self.pod.id483 #create new vlan ip range484 new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])485 self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))486 self.cleanup.append(new_vlan)487 new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id)488 #Compare list output with configured values489 self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"])...
first_esoteric.py
Source:first_esoteric.py
1__builtins__.__getattribute__("print")(2 __builtins__.__getattribute__("chr")(3 __builtins__.__getattribute__("bool").__add__(4 __builtins__.__getattribute__("bool")(" ").__lshift__(5 __builtins__.__getattribute__("bool").__add__(6 __builtins__.__getattribute__("bool").__add__(7 __builtins__.__getattribute__("bool")(" "),8 __builtins__.__getattribute__("bool")(" ")9 ),10 __builtins__.__getattribute__("bool")(" ")11 )12 ), 13 __builtins__.__getattribute__("bool")(" ").__lshift__(14 __builtins__.__getattribute__("bool").__add__(15 __builtins__.__getattribute__("bool").__add__(16 __builtins__.__getattribute__("bool").__add__(17 __builtins__.__getattribute__("bool").__add__(18 __builtins__.__getattribute__("bool").__add__(19 __builtins__.__getattribute__("bool")(" "),20 __builtins__.__getattribute__("bool")(" ")21 ),22 __builtins__.__getattribute__("bool")(" ")23 ),24 __builtins__.__getattribute__("bool")(" ")25 ),26 __builtins__.__getattribute__("bool")(" ")27 ),28 __builtins__.__getattribute__("bool")(" ")29 )30 )31 )32 ), end = ""33)34__builtins__.__getattribute__("print")(35 __builtins__.__getattribute__("chr")(36 __builtins__.__getattribute__("bool").__add__(37 __builtins__.__getattribute__("bool").__add__(38 __builtins__.__getattribute__("bool")(" "),39 __builtins__.__getattribute__("bool")(" ").__lshift__(40 __builtins__.__getattribute__("bool").__add__(41 __builtins__.__getattribute__("bool")(" "),42 __builtins__.__getattribute__("bool")(" ")43 )44 )45 ),46 __builtins__.__getattribute__("bool").__add__(47 __builtins__.__getattribute__("bool")(" ").__lshift__(48 __builtins__.__getattribute__("bool").__add__(49 __builtins__.__getattribute__("bool").__add__(50 __builtins__.__getattribute__("bool").__add__(51 __builtins__.__getattribute__("bool").__add__(52 __builtins__.__getattribute__("bool")(" "),53 __builtins__.__getattribute__("bool")(" ")54 ),55 __builtins__.__getattribute__("bool")(" ")56 ),57 __builtins__.__getattribute__("bool")(" ")58 ),59 __builtins__.__getattribute__("bool")(" ")60 )61 ),62 __builtins__.__getattribute__("bool")(" ").__lshift__(63 __builtins__.__getattribute__("bool").__add__(64 __builtins__.__getattribute__("bool").__add__(65 __builtins__.__getattribute__("bool").__add__(66 __builtins__.__getattribute__("bool").__add__(67 __builtins__.__getattribute__("bool").__add__(68 __builtins__.__getattribute__("bool")(" "),69 __builtins__.__getattribute__("bool")(" ")70 ),71 __builtins__.__getattribute__("bool")(" ")72 ),73 __builtins__.__getattribute__("bool")(" ")74 ),75 __builtins__.__getattribute__("bool")(" ")76 ),77 __builtins__.__getattribute__("bool")(" ")78 )79 )80 )81 )82 ), end = ""83)84__builtins__.__getattribute__("print")(85 __builtins__.__getattribute__("chr")(86 __builtins__.__getattribute__("bool").__add__(87 __builtins__.__getattribute__("bool").__add__(88 __builtins__.__getattribute__("bool")(" ").__lshift__(89 __builtins__.__getattribute__("bool").__add__(90 __builtins__.__getattribute__("bool")(" "),91 __builtins__.__getattribute__("bool")(" ")92 )93 ),94 __builtins__.__getattribute__("bool")(" ").__lshift__(95 __builtins__.__getattribute__("bool").__add__(96 __builtins__.__getattribute__("bool").__add__(97 __builtins__.__getattribute__("bool")(" "),98 __builtins__.__getattribute__("bool")(" ")99 ), 100 __builtins__.__getattribute__("bool")(" ")101 )102 )103 ),104 __builtins__.__getattribute__("bool").__add__(105 __builtins__.__getattribute__("bool")(" ").__lshift__(106 __builtins__.__getattribute__("bool").__add__(107 __builtins__.__getattribute__("bool").__add__(108 __builtins__.__getattribute__("bool").__add__(109 __builtins__.__getattribute__("bool").__add__(110 __builtins__.__getattribute__("bool")(" "),111 __builtins__.__getattribute__("bool")(" ")112 ),113 __builtins__.__getattribute__("bool")(" ")114 ),115 __builtins__.__getattribute__("bool")(" ")116 ),117 __builtins__.__getattribute__("bool")(" ")118 )119 ),120 __builtins__.__getattribute__("bool")(" ").__lshift__(121 __builtins__.__getattribute__("bool").__add__(122 __builtins__.__getattribute__("bool").__add__(123 __builtins__.__getattribute__("bool").__add__(124 __builtins__.__getattribute__("bool").__add__(125 __builtins__.__getattribute__("bool").__add__(126 __builtins__.__getattribute__("bool")(" "),127 __builtins__.__getattribute__("bool")(" ")128 ),129 __builtins__.__getattribute__("bool")(" ")130 ),131 __builtins__.__getattribute__("bool")(" ")132 ),133 __builtins__.__getattribute__("bool")(" ")134 ),135 __builtins__.__getattribute__("bool")(" ")136 )137 )138 )139 )140 ), end = ""141)142__builtins__.__getattribute__("print")(143 __builtins__.__getattribute__("chr")(144 __builtins__.__getattribute__("bool").__add__(145 __builtins__.__getattribute__("bool").__add__(146 __builtins__.__getattribute__("bool")(" ").__lshift__(147 __builtins__.__getattribute__("bool").__add__(148 __builtins__.__getattribute__("bool")(" "),149 __builtins__.__getattribute__("bool")(" ")150 )151 ),152 __builtins__.__getattribute__("bool")(" ").__lshift__(153 __builtins__.__getattribute__("bool").__add__(154 __builtins__.__getattribute__("bool").__add__(155 __builtins__.__getattribute__("bool")(" "),156 __builtins__.__getattribute__("bool")(" ")157 ), 158 __builtins__.__getattribute__("bool")(" ")159 )160 )161 ),162 __builtins__.__getattribute__("bool").__add__(163 __builtins__.__getattribute__("bool")(" ").__lshift__(164 __builtins__.__getattribute__("bool").__add__(165 __builtins__.__getattribute__("bool").__add__(166 __builtins__.__getattribute__("bool").__add__(167 __builtins__.__getattribute__("bool").__add__(168 __builtins__.__getattribute__("bool")(" "),169 __builtins__.__getattribute__("bool")(" ")170 ),171 __builtins__.__getattribute__("bool")(" ")172 ),173 __builtins__.__getattribute__("bool")(" ")174 ),175 __builtins__.__getattribute__("bool")(" ")176 )177 ),178 __builtins__.__getattribute__("bool")(" ").__lshift__(179 __builtins__.__getattribute__("bool").__add__(180 __builtins__.__getattribute__("bool").__add__(181 __builtins__.__getattribute__("bool").__add__(182 __builtins__.__getattribute__("bool").__add__(183 __builtins__.__getattribute__("bool").__add__(184 __builtins__.__getattribute__("bool")(" "),185 __builtins__.__getattribute__("bool")(" ")186 ),187 __builtins__.__getattribute__("bool")(" ")188 ),189 __builtins__.__getattribute__("bool")(" ")190 ),191 __builtins__.__getattribute__("bool")(" ")192 ),193 __builtins__.__getattribute__("bool")(" ")194 )195 )196 )197 )198 ), end = ""199)200__builtins__.__getattribute__("print")(201 __builtins__.__getattribute__("chr")(202 __builtins__.__getattribute__("bool").__add__(203 __builtins__.__getattribute__("bool").__add__(204 __builtins__.__getattribute__("bool").__add__(205 __builtins__.__getattribute__("bool")(" "),206 __builtins__.__getattribute__("bool")(" ").__lshift__(207 __builtins__.__getattribute__("bool")(" ")208 )209 ),210 __builtins__.__getattribute__("bool")(" ").__lshift__(211 __builtins__.__getattribute__("bool").__add__(212 __builtins__.__getattribute__("bool")(" "),213 __builtins__.__getattribute__("bool")(" ")214 )215 )216 ),217 __builtins__.__getattribute__("bool").__add__(218 __builtins__.__getattribute__("bool").__add__(219 __builtins__.__getattribute__("bool")(" ").__lshift__(220 __builtins__.__getattribute__("bool").__add__(221 __builtins__.__getattribute__("bool").__add__(222 __builtins__.__getattribute__("bool")(" "),223 __builtins__.__getattribute__("bool")(" ")224 ), 225 __builtins__.__getattribute__("bool")(" ")226 )227 ),228 __builtins__.__getattribute__("bool")(" ").__lshift__(229 __builtins__.__getattribute__("bool").__add__(230 __builtins__.__getattribute__("bool").__add__(231 __builtins__.__getattribute__("bool").__add__(232 __builtins__.__getattribute__("bool").__add__(233 __builtins__.__getattribute__("bool")(" "),234 __builtins__.__getattribute__("bool")(" ")235 ),236 __builtins__.__getattribute__("bool")(" ")237 ),238 __builtins__.__getattribute__("bool")(" ")239 ),240 __builtins__.__getattribute__("bool")(" ")241 )242 )243 ), __builtins__.__getattribute__("bool")(" ").__lshift__(244 __builtins__.__getattribute__("bool").__add__(245 __builtins__.__getattribute__("bool").__add__(246 __builtins__.__getattribute__("bool").__add__(247 __builtins__.__getattribute__("bool").__add__(248 __builtins__.__getattribute__("bool").__add__(249 __builtins__.__getattribute__("bool")(" "),250 __builtins__.__getattribute__("bool")(" ")251 ),252 __builtins__.__getattribute__("bool")(" ")253 ),254 __builtins__.__getattribute__("bool")(" ")255 ),256 __builtins__.__getattribute__("bool")(" ")257 ),258 __builtins__.__getattribute__("bool")(" ")259 )260 )261 )262 )263 ), end = ""264)265__builtins__.__getattribute__("print")(266 __builtins__.__getattribute__("chr")(267 __builtins__.__getattribute__("bool")(" ").__lshift__(268 __builtins__.__getattribute__("bool").__add__(269 __builtins__.__getattribute__("bool").__add__(270 __builtins__.__getattribute__("bool").__add__(271 __builtins__.__getattribute__("bool").__add__(272 __builtins__.__getattribute__("bool")(" "),273 __builtins__.__getattribute__("bool")(" ")274 ),275 __builtins__.__getattribute__("bool")(" ")276 ),277 __builtins__.__getattribute__("bool")(" ")278 ),279 __builtins__.__getattribute__("bool")(" ")280 )281 )282 ), end = ""283)284__builtins__.__getattribute__("print")(285 __builtins__.__getattribute__("chr")(286 __builtins__.__getattribute__("bool").__add__(287 __builtins__.__getattribute__("bool").__add__(288 __builtins__.__getattribute__("bool").__add__(289 __builtins__.__getattribute__("bool")(" "),290 __builtins__.__getattribute__("bool").__add__(291 __builtins__.__getattribute__("bool")(" "),292 __builtins__.__getattribute__("bool")(" ")293 )294 ),295 __builtins__.__getattribute__("bool")(" ").__lshift__(296 __builtins__.__getattribute__("bool").__add__(297 __builtins__.__getattribute__("bool")(" "),298 __builtins__.__getattribute__("bool")(" ")299 )300 )301 ),302 __builtins__.__getattribute__("bool").__add__(303 __builtins__.__getattribute__("bool")(" ").__lshift__(304 __builtins__.__getattribute__("bool").__add__(305 __builtins__.__getattribute__("bool").__add__(306 __builtins__.__getattribute__("bool").__add__(307 __builtins__.__getattribute__("bool")(" "),308 __builtins__.__getattribute__("bool")(" ")309 ),310 __builtins__.__getattribute__("bool")(" ")311 ),312 __builtins__.__getattribute__("bool")(" ")313 )314 ), 315 __builtins__.__getattribute__("bool")(" ").__lshift__(316 __builtins__.__getattribute__("bool").__add__(317 __builtins__.__getattribute__("bool").__add__(318 __builtins__.__getattribute__("bool").__add__(319 __builtins__.__getattribute__("bool").__add__(320 __builtins__.__getattribute__("bool").__add__(321 __builtins__.__getattribute__("bool")(" "),322 __builtins__.__getattribute__("bool")(" ")323 ),324 __builtins__.__getattribute__("bool")(" ")325 ),326 __builtins__.__getattribute__("bool")(" ")327 ),328 __builtins__.__getattribute__("bool")(" ")329 ),330 __builtins__.__getattribute__("bool")(" ")331 )332 )333 )334 )335 ), end = ""336)337__builtins__.__getattribute__("print")(338 __builtins__.__getattribute__("chr")(339 __builtins__.__getattribute__("bool").__add__(340 __builtins__.__getattribute__("bool").__add__(341 __builtins__.__getattribute__("bool").__add__(342 __builtins__.__getattribute__("bool")(" "),343 __builtins__.__getattribute__("bool")(" ").__lshift__(344 __builtins__.__getattribute__("bool")(" ")345 )346 ),347 __builtins__.__getattribute__("bool")(" ").__lshift__(348 __builtins__.__getattribute__("bool").__add__(349 __builtins__.__getattribute__("bool")(" "),350 __builtins__.__getattribute__("bool")(" ")351 )352 )353 ),354 __builtins__.__getattribute__("bool").__add__(355 __builtins__.__getattribute__("bool").__add__(356 __builtins__.__getattribute__("bool")(" ").__lshift__(357 __builtins__.__getattribute__("bool").__add__(358 __builtins__.__getattribute__("bool").__add__(359 __builtins__.__getattribute__("bool")(" "),360 __builtins__.__getattribute__("bool")(" ")361 ), 362 __builtins__.__getattribute__("bool")(" ")363 )364 ),365 __builtins__.__getattribute__("bool")(" ").__lshift__(366 __builtins__.__getattribute__("bool").__add__(367 __builtins__.__getattribute__("bool").__add__(368 __builtins__.__getattribute__("bool").__add__(369 __builtins__.__getattribute__("bool").__add__(370 __builtins__.__getattribute__("bool")(" "),371 __builtins__.__getattribute__("bool")(" ")372 ),373 __builtins__.__getattribute__("bool")(" ")374 ),375 __builtins__.__getattribute__("bool")(" ")376 ),377 __builtins__.__getattribute__("bool")(" ")378 )379 )380 ), __builtins__.__getattribute__("bool")(" ").__lshift__(381 __builtins__.__getattribute__("bool").__add__(382 __builtins__.__getattribute__("bool").__add__(383 __builtins__.__getattribute__("bool").__add__(384 __builtins__.__getattribute__("bool").__add__(385 __builtins__.__getattribute__("bool").__add__(386 __builtins__.__getattribute__("bool")(" "),387 __builtins__.__getattribute__("bool")(" ")388 ),389 __builtins__.__getattribute__("bool")(" ")390 ),391 __builtins__.__getattribute__("bool")(" ")392 ),393 __builtins__.__getattribute__("bool")(" ")394 ),395 __builtins__.__getattribute__("bool")(" ")396 )397 )398 )399 )400 ), end = ""401)402__builtins__.__getattribute__("print")(403 __builtins__.__getattribute__("chr")(404 __builtins__.__getattribute__("bool").__add__(405 __builtins__.__getattribute__("bool").__add__(406 __builtins__.__getattribute__("bool").__add__(407 __builtins__.__getattribute__("bool")(" "),408 __builtins__.__getattribute__("bool")(" ")409 ),410 __builtins__.__getattribute__("bool")(" ").__lshift__(411 __builtins__.__getattribute__("bool").__add__(412 __builtins__.__getattribute__("bool").__add__(413 __builtins__.__getattribute__("bool").__add__(414 __builtins__.__getattribute__("bool")(" "),415 __builtins__.__getattribute__("bool")(" ")416 ),417 __builtins__.__getattribute__("bool")(" ")418 ),419 __builtins__.__getattribute__("bool")(" ")420 )421 )422 ),423 __builtins__.__getattribute__("bool").__add__(424 __builtins__.__getattribute__("bool")(" ").__lshift__(425 __builtins__.__getattribute__("bool").__add__(426 __builtins__.__getattribute__("bool").__add__(427 __builtins__.__getattribute__("bool").__add__(428 __builtins__.__getattribute__("bool").__add__(429 __builtins__.__getattribute__("bool")(" "),430 __builtins__.__getattribute__("bool")(" ")431 ),432 __builtins__.__getattribute__("bool")(" ")433 ),434 __builtins__.__getattribute__("bool")(" ")435 ),436 __builtins__.__getattribute__("bool")(" ")437 )438 ),439 __builtins__.__getattribute__("bool")(" ").__lshift__(440 __builtins__.__getattribute__("bool").__add__(441 __builtins__.__getattribute__("bool").__add__(442 __builtins__.__getattribute__("bool").__add__(443 __builtins__.__getattribute__("bool").__add__(444 __builtins__.__getattribute__("bool").__add__(445 __builtins__.__getattribute__("bool")(" "),446 __builtins__.__getattribute__("bool")(" ")447 ),448 __builtins__.__getattribute__("bool")(" ")449 ),450 __builtins__.__getattribute__("bool")(" ")451 ),452 __builtins__.__getattribute__("bool")(" ")453 ),454 __builtins__.__getattribute__("bool")(" ")455 )456 )457 )458 )459 ), end = ""460)461__builtins__.__getattribute__("print")(462 __builtins__.__getattribute__("chr")(463 __builtins__.__getattribute__("bool").__add__(464 __builtins__.__getattribute__("bool").__add__(465 __builtins__.__getattribute__("bool")(" ").__lshift__(466 __builtins__.__getattribute__("bool").__add__(467 __builtins__.__getattribute__("bool")(" "),468 __builtins__.__getattribute__("bool")(" ")469 )470 ),471 __builtins__.__getattribute__("bool")(" ").__lshift__(472 __builtins__.__getattribute__("bool").__add__(473 __builtins__.__getattribute__("bool").__add__(474 __builtins__.__getattribute__("bool")(" "),475 __builtins__.__getattribute__("bool")(" ")476 ), 477 __builtins__.__getattribute__("bool")(" ")478 )479 )480 ),481 __builtins__.__getattribute__("bool").__add__(482 __builtins__.__getattribute__("bool")(" ").__lshift__(483 __builtins__.__getattribute__("bool").__add__(484 __builtins__.__getattribute__("bool").__add__(485 __builtins__.__getattribute__("bool").__add__(486 __builtins__.__getattribute__("bool").__add__(487 __builtins__.__getattribute__("bool")(" "),488 __builtins__.__getattribute__("bool")(" ")489 ),490 __builtins__.__getattribute__("bool")(" ")491 ),492 __builtins__.__getattribute__("bool")(" ")493 ),494 __builtins__.__getattribute__("bool")(" ")495 )496 ),497 __builtins__.__getattribute__("bool")(" ").__lshift__(498 __builtins__.__getattribute__("bool").__add__(499 __builtins__.__getattribute__("bool").__add__(500 __builtins__.__getattribute__("bool").__add__(501 __builtins__.__getattribute__("bool").__add__(502 __builtins__.__getattribute__("bool").__add__(503 __builtins__.__getattribute__("bool")(" "),504 __builtins__.__getattribute__("bool")(" ")505 ),506 __builtins__.__getattribute__("bool")(" ")507 ),508 __builtins__.__getattribute__("bool")(" ")509 ),510 __builtins__.__getattribute__("bool")(" ")511 ),512 __builtins__.__getattribute__("bool")(" ")513 )514 )515 )516 )517 ), end = ""518)519__builtins__.__getattribute__("print")(520 __builtins__.__getattribute__("chr")(521 __builtins__.__getattribute__("bool").__add__(522 __builtins__.__getattribute__("bool")(" ").__lshift__(523 __builtins__.__getattribute__("bool").__add__(524 __builtins__.__getattribute__("bool")(" "),525 __builtins__.__getattribute__("bool")(" ")526 )527 ),528 __builtins__.__getattribute__("bool").__add__(529 __builtins__.__getattribute__("bool")(" ").__lshift__(530 __builtins__.__getattribute__("bool").__add__(531 __builtins__.__getattribute__("bool").__add__(532 __builtins__.__getattribute__("bool").__add__(533 __builtins__.__getattribute__("bool").__add__(534 __builtins__.__getattribute__("bool")(" "),535 __builtins__.__getattribute__("bool")(" ")536 ),537 __builtins__.__getattribute__("bool")(" ")538 ),539 __builtins__.__getattribute__("bool")(" ")540 ),541 __builtins__.__getattribute__("bool")(" ")542 )543 ),544 __builtins__.__getattribute__("bool")(" ").__lshift__(545 __builtins__.__getattribute__("bool").__add__(546 __builtins__.__getattribute__("bool").__add__(547 __builtins__.__getattribute__("bool").__add__(548 __builtins__.__getattribute__("bool").__add__(549 __builtins__.__getattribute__("bool").__add__(550 __builtins__.__getattribute__("bool")(" "),551 __builtins__.__getattribute__("bool")(" ")552 ),553 __builtins__.__getattribute__("bool")(" ")554 ),555 __builtins__.__getattribute__("bool")(" ")556 ),557 __builtins__.__getattribute__("bool")(" ")558 ),559 __builtins__.__getattribute__("bool")(" ")560 )561 )562 )563 )564 ), end = ""565)566__builtins__.__getattribute__("print")(567 __builtins__.__getattribute__("chr")(568 __builtins__.__getattribute__("bool")(" ").__lshift__(569 __builtins__.__getattribute__("bool").__add__(570 __builtins__.__getattribute__("bool").__add__(571 __builtins__.__getattribute__("bool").__add__(572 __builtins__.__getattribute__("bool").__add__(573 __builtins__.__getattribute__("bool")(" "),574 __builtins__.__getattribute__("bool")(" ")575 ),576 __builtins__.__getattribute__("bool")(" ")577 ),578 __builtins__.__getattribute__("bool")(" ")579 ),580 __builtins__.__getattribute__("bool")(" ")581 )582 )583 ), end = ""584)585__builtins__.__getattribute__("print")(586 __builtins__.__getattribute__("chr")(587 __builtins__.__getattribute__("bool").__add__(588 __builtins__.__getattribute__("bool")(" "),589 __builtins__.__getattribute__("bool")(" ").__lshift__(590 __builtins__.__getattribute__("bool").__add__(591 __builtins__.__getattribute__("bool").__add__(592 __builtins__.__getattribute__("bool").__add__(593 __builtins__.__getattribute__("bool").__add__(594 __builtins__.__getattribute__("bool")(" "),595 __builtins__.__getattribute__("bool")(" ")596 ),597 __builtins__.__getattribute__("bool")(" ")598 ),599 __builtins__.__getattribute__("bool")(" ")600 ),601 __builtins__.__getattribute__("bool")(" ")602 )603 )604 )605 )...
DBManager.py
Source:DBManager.py
...30 else:31 logger.info('Connecting data base')32 self.__connect()33 logger.info('Creating table model_checkpoint')34 query = "CREATE TABLE IF NOT EXISTS model_checkpoint (".__add__(35 "id integer PRIMARY KEY,").__add__(36 "datetime int NOT NULL,").__add__(37 "user text NOT NULL,").__add__(38 "machine text NOT NULL,").__add__(39 "model_name text NOT NULL,").__add__(40 "model_version text NOT NULL,").__add__(41 "checkpoint_status text NOT NULL,").__add__(42 "checkpoint_path text NOT NULL)")43 self.__cursor.execute(query)44 logger.info('Creating table model_info')45 query = "CREATE TABLE IF NOT EXISTS model_info (".__add__(46 "name text NOT NULL,").__add__(47 "version text NOT NULL,").__add__(48 "status text NOT NULL,").__add__(49 "path text NOT NULL,").__add__(50 "CONSTRAINT pk_model_info PRIMARY KEY (name, version))")51 self.__cursor.execute(query)52 logger.info('Creating table noise_files')53 query = "CREATE TABLE IF NOT EXISTS noise_files (".__add__(54 "id integer PRIMARY KEY,").__add__(55 "name text NOT NULL,").__add__(56 "url text NOT NULL,").__add__(57 "path text NOT NULL,").__add__(58 "channels int NOT NULL,").__add__(59 "sample_rate int NOT NULL,").__add__(60 "duration real NOT NULL,").__add__(61 "status text NOT NULL,").__add__(62 "insert_datetime int NOT NULL)")63 self.__cursor.execute(query)64 logger.info('Creating table audio_books_tracks')65 query = "CREATE TABLE IF NOT EXISTS audio_books_tracks (".__add__(66 "id integer PRIMARY KEY,").__add__(67 "book_dummy_name text NOT NULL,").__add__(68 "book_name text NOT NULL,").__add__(69 "book_author text NOT NULL,").__add__(70 "book_url text NOT NULL,").__add__(71 "book_language text NOT NULL,").__add__(72 "book_path text NOT NULL,").__add__(73 "book_n_tracks int NOT NULL,").__add__(74 "track_name text NOT NULL,").__add__(75 "track_path text NOT NULL,").__add__(76 "track_channels int NOT NULL,").__add__(77 "track_sample_rate int NOT NULL,").__add__(78 "track_duration real NOT NULL,").__add__(79 "track_status text NOT NULL,").__add__(80 "track_insert_datetime int NOT NULL)")81 self.__cursor.execute(query)82 logger.info('Creating table training_track')83 query = "CREATE TABLE IF NOT EXISTS training_track (".__add__(84 "id integer PRIMARY KEY,").__add__(85 "model_name text NOT NULL,").__add__(86 "model_version text NOT NULL,").__add__(87 "start_checkpoint_id integer NOT NULL,").__add__(88 "end_checkpoint_id integer NOT NULL,").__add__(89 "audio_book_track_id integer NOT NULL,").__add__(90 "noise_id integer NOT NULL,").__add__(91 "epoch integer NOT NULL,").__add__(92 "status text NOT NULL,").__add__(93 "insert_datetime int NOT NULL)")94 self.__cursor.execute(query)95 logger.info('Committing changes')96 self.__conn.commit()97 logger.info('Closing connection')98 self.__close()99 except Exception:100 self.__close()101 def noiseExist(self, name):102 try:103 self.__connect()104 self.__cursor.execute(105 "SELECT name " +106 "FROM noise_files " +107 "WHERE name = '" + name + "'"108 )109 cursorVal = self.__cursor.fetchall()110 if not cursorVal:111 retVal = False112 else:113 retVal = True114 self.__close()115 return retVal116 except Exception as error:117 self.__close()118 logging.error(str(error), exc_info=True)119 raise120 def noiseCreate(self, name, url, path, channels, sampleRate, duration):121 try:122 self.__connect()123 self.__cursor.execute(124 "SELECT COALESCE(MAX(id) + 1,1) FROM noise_files"125 )126 newId = self.__cursor.fetchall()127 query = "INSERT INTO noise_files ".__add__(128 "(id, name, url, path, channels, sample_rate, duration, status, insert_datetime) ").__add__(129 "VALUES (?,?,?,?,?,?,?,?, datetime('now'))")130 self.__cursor.execute(query, [int(newId[0][0]), name, url, path,131 int(channels), int(sampleRate), duration, "OK"])132 self.__conn.commit()133 self.__close()134 except Exception as error:135 self.__close()136 logging.error(str(error), exc_info=True)137 raise138 def noiseGetByName(self, name):139 try:140 self.__connect()141 self.__cursor.execute(142 "SELECT * FROM noise_files " +143 "WHERE name = '" + name + "' " +144 "ORDER BY insert_datetime DESC " +145 "LIMIT 1"146 )147 retQuery = self.__cursor.fetchall()148 self.__close()149 return retQuery150 except Exception as error:151 self.__close()152 logging.error(str(error), exc_info=True)153 raise154 def noiseGetById(self, noiseId):155 try:156 self.__connect()157 self.__cursor.execute(158 "SELECT * FROM noise_files " +159 "WHERE id = " + str(noiseId) + " " +160 "ORDER BY insert_datetime DESC " +161 "LIMIT 1"162 )163 retQuery = self.__cursor.fetchall()164 self.__close()165 return retQuery166 except Exception as error:167 self.__close()168 logging.error(str(error), exc_info=True)169 raise170 def noiseUpdateStatusByName(self, name, status):171 try:172 self.__connect()173 query = "UPDATE noise_files ".__add__(174 "SET status = '" + status + "' ").__add__(175 "WHERE id = ( ").__add__(176 "SELECT id ").__add__(177 "FROM noise_files ").__add__(178 "WHERE name = '" + name + "' ").__add__(179 "ORDER BY insert_datetime DESC ").__add__(180 "LIMIT 1").__add__(181 ")")182 self.__cursor.execute(query)183 self.__conn.commit()184 self.__close()185 except Exception as error:186 self.__close()187 logging.error(str(error), exc_info=True)188 raise189 def modelExist(self, name):190 try:191 self.__connect()192 self.__cursor.execute(193 "SELECT name " +194 "FROM model_info " +195 "WHERE name = '" + name + "'"196 )197 cursorVal = self.__cursor.fetchall()198 if not cursorVal:199 retVal = False200 else:201 retVal = True202 self.__close()203 return retVal204 except Exception as error:205 self.__close()206 logging.error(str(error), exc_info=True)207 raise208 def modelCreate(self, name, version, pyFilePath, checkpointPath):209 try:210 self.__connect()211 query = "INSERT INTO model_info ".__add__(212 "(name, version, status, path) ").__add__(213 "VALUES (?,?,?,?)")214 self.__cursor.execute(query, [name, version, "CREATED", pyFilePath])215 self.__conn.commit()216 self.__close()217 self.modelCreateCheckpoint(name, version, checkpointPath, "CREATED")218 except Exception as error:219 self.__close()220 logging.error(str(error), exc_info=True)221 raise222 def modelCreateCheckpoint(self, name, version, checkpointPath, checkpoint_status):223 try:224 self.__connect()225 self.__cursor.execute(226 "SELECT COALESCE(MAX(id) + 1,1) FROM model_checkpoint"227 )228 newId = self.__cursor.fetchall()[0][0]229 query = "INSERT INTO model_checkpoint ".__add__(230 "(id, datetime, user, machine, model_name, model_version, ").__add__(231 "checkpoint_status, checkpoint_path) ").__add__(232 "VALUES (?,datetime('now'),?,?,?,?,?,?)")233 self.__cursor.execute(query, [int(newId), getuser(),234 gethostname(), name, version, checkpoint_status, checkpointPath])235 self.__conn.commit()236 self.__close()237 except Exception as error:238 self.__close()239 logging.error(str(error), exc_info=True)240 raise241 def modelGetInfo(self, name, ver):242 try:243 self.__connect()244 query = "SELECT * ".__add__(245 "FROM model_info ").__add__(246 "WHERE name ='" + name + "'").__add__(247 "AND version = '" + ver + "'")248 self.__cursor.execute(query)249 cursorVal = self.__cursor.fetchall()250 if not cursorVal:251 retVal = None252 else:253 retVal = {'name' : cursorVal[0][0],254 'version' : cursorVal[0][1],255 'status' : cursorVal[0][2],256 'path' : cursorVal[0][3]}257 query = "SELECT * ".__add__(258 "FROM model_checkpoint ").__add__(259 "WHERE model_name ='" + name + "' ").__add__(260 "AND model_version ='" + ver + "' ").__add__(261 "ORDER BY datetime DESC ").__add__(262 "LIMIT 1")263 self.__cursor.execute(query)264 cursorVal = self.__cursor.fetchall()265 retVal['checkpoint_status'] = cursorVal[0][6]266 retVal['checkpoint_path'] = cursorVal[0][7]267 self.__close()268 return retVal269 except Exception as error:270 self.__close()271 logging.error(str(error), exc_info=True)272 raise273 def modelTrainNext(self, name, ver):274 try:275 self.__connect()276 query = "SELECT * ".__add__(277 "FROM training_track ").__add__(278 "WHERE model_name ='" + name + "' ").__add__(279 "AND model_version = '" + ver + "' ").__add__(280 "AND status = 'NO TRAINED' ").__add__(281 "ORDER BY id ASC ").__add__(282 "LIMIT 1"283 )284 self.__cursor.execute(query)285 cursorVal = self.__cursor.fetchall()286 self.__close()287 return cursorVal288 except Exception as error:289 self.__close()290 logging.error(str(error), exc_info=True)291 raise292 def modelTrainNewEpoch(self, name, ver, target_sample_rate):293 try:294 self.__connect()295 self.__cursor.execute(296 "SELECT COALESCE(MAX(epoch) + 1,1) FROM training_track " +297 "WHERE model_name = '" + name + "' " +298 "AND model_version = '" + ver + "' "299 )300 newEpoch = self.__cursor.fetchall()[0][0]301 self.__cursor.execute(302 "SELECT MAX(id) FROM model_checkpoint " +303 "WHERE model_name = '" + name + "' " +304 "AND model_version = '" + ver + "' "305 )306 start_checkpoint_id = self.__cursor.fetchall()[0][0]307 query = "INSERT INTO training_track ".__add__(308 "SELECT ROW_NUMBER() OVER ( ORDER BY tracks.id, noise.id ) + ").__add__(309 str(int(newEpoch - 1)) + " AS id,").__add__(310 "'" + name + "' as model_name,").__add__(311 "'" + ver + "' as model_ver,").__add__(312 str(start_checkpoint_id) + " as start_checkpoint_id,").__add__(313 str(-1) + " as end_checkpoint_id,").__add__(314 "tracks.id as audio_book_track_id," ).__add__(315 "noise.id as noise_id,").__add__(316 str(newEpoch) + " as epoch,").__add__(317 "'NO TRAINED' as status,").__add__(318 "datetime('now') as insert_datetime ").__add__(319 "FROM audio_books_tracks AS tracks ").__add__(320 "JOIN noise_files AS noise ").__add__(321 "ON 1=1 ").__add__(322 r"WHERE (tracks.track_sample_rate%" + "%d) = 0 " % target_sample_rate).__add__(323 r"AND (noise.sample_rate%" + "%d) = 0" % target_sample_rate)324 self.__cursor.execute(query)325 self.__conn.commit()326 self.__close()327 except Exception as error:328 self.__close()329 logging.error(str(error), exc_info=True)330 raise331 def modelTrainGetCombination(self, target_sample_rate, noises, limit):332 try:333 self.__connect()334 query = "SELECT ROW_NUMBER() OVER ( ORDER BY tracks.id, noise.id ), ".__add__(335 "tracks.id as audio_book_track_id,").__add__(336 "noise.id as noise_id ").__add__(337 "FROM audio_books_tracks AS tracks ").__add__(338 "JOIN noise_files AS noise ").__add__(339 "ON 1=1 ").__add__(340 r"WHERE (tracks.track_sample_rate%" + "%d) = 0 " % target_sample_rate).__add__(341 r"AND (noise.sample_rate%" + "%d) = 0 " % target_sample_rate).__add__(342 r"AND noise.name IN ('" + "','".join(noises) + "') ").__add__(343 "GROUP BY tracks.track_name")344 if limit != 0:345 query += " LIMIT %d" % limit346 self.__cursor.execute(query)347 ret_val = self.__cursor.fetchall()348 self.__close()349 return ret_val350 except Exception as error:351 self.__close()352 logging.error(str(error), exc_info=True)353 raise354 def modelTrainUpdateStatus(self, id_training_track, status):355 try:356 self.__connect()357 query = "UPDATE training_track ".__add__(358 "SET status = '" + status + "' ").__add__(359 "WHERE id = " + str(id_training_track))360 self.__cursor.execute(query)361 self.__conn.commit()362 self.__close()363 except Exception as error:364 self.__close()365 logging.error(str(error), exc_info=True)366 raise367 def audioBookExist(self, name):368 try:369 self.__connect()370 self.__cursor.execute(371 "SELECT book_dummy_name " +372 "FROM audio_books_tracks " +373 "WHERE book_name = '" + name + "'"374 )375 cursorVal = self.__cursor.fetchall()376 if not cursorVal:377 retVal = False378 else:379 retVal = True380 self.__close()381 return retVal382 except Exception as error:383 self.__close()384 logging.error(str(error), exc_info=True)385 raise386 def audioBookCreate(self, trackList):387 try:388 self.__connect()389 for track in trackList:390 self.__cursor.execute(391 "SELECT COALESCE(MAX(id) + 1,1) FROM audio_books_tracks"392 )393 newId = self.__cursor.fetchall()394 query = "INSERT INTO audio_books_tracks ".__add__(395 "(id, book_dummy_name, book_name, book_author, book_url, book_language, book_path, ").__add__(396 "book_n_tracks, track_name, track_path, track_channels, track_sample_rate, ").__add__(397 "track_duration, track_status, track_insert_datetime) ").__add__(398 "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?, datetime('now'))")399 self.__cursor.execute(query, [int(newId[0][0]), track.dummy, track.title, track.authorName, track.url,400 track.language, track.zip, track.nTracks, track.name, track.path, track.channels,401 track.sampleRate, track.duration, "OK"])402 self.__conn.commit()403 self.__close()404 except Exception as error:405 self.__close()406 logging.error(str(error), exc_info=True)407 raise408 def audioBookGetByName(self, name):409 try:410 self.__connect()411 self.__cursor.execute(412 "SELECT book_n_tracks FROM audio_books_tracks " +413 "WHERE book_name = '" + name + "' " +414 "ORDER BY track_insert_datetime DESC " +415 "LIMIT 1"416 )417 nTracks = self.__cursor.fetchall()418 self.__cursor.execute(419 "SELECT * FROM audio_books_tracks " +420 "WHERE book_name = '" + name + "' " +421 "ORDER BY insert_datetime DESC " +422 "LIMIT " + str(int(nTracks[0][0]))423 )424 retQuery = self.__cursor.fetchall()425 self.__close()426 return retQuery427 except Exception as error:428 self.__close()429 return None430 def audioBookGetById(self, trackId):431 try:432 self.__connect()433 self.__cursor.execute(434 "SELECT * FROM audio_books_tracks " +435 "WHERE id = " + str(trackId) + " " +436 "ORDER BY track_insert_datetime DESC " +437 "LIMIT 1"438 )439 retQuery = self.__cursor.fetchall()440 self.__close()441 return retQuery442 except Exception as error:443 self.__close()444 logging.error(str(error), exc_info=True)445 raise446 def audioBookUpdateStatusByName(self, name, status):447 try:448 self.__connect()449 self.__cursor.execute(450 "SELECT book_n_tracks FROM audio_books_tracks " +451 "WHERE book_name = '" + name + "' " +452 "ORDER BY track_insert_datetime DESC " +453 "LIMIT 1"454 )455 nTracks = self.__cursor.fetchall()456 query = "UPDATE audio_books_tracks ".__add__(457 "SET status = '" + status + "' ").__add__(458 "WHERE book_name = " + "'" + name + "' ").__add__(459 "ORDER BY insert_datetime DESC ").__add__(460 "LIMIT " + str(int(nTracks[0][0]))461 )462 self.__cursor.execute(query)463 self.__conn.commit()464 self.__close()465 except Exception as error:466 self.__close()467 logging.error(str(error), exc_info=True)468 raise469if __name__ == '__main__':470 bdManager = DBManager()...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!