Best Python code snippet using slash
function.py
Source:function.py  
...125            except subprocess.CalledProcessError as error_output:126                print('Install \033[1;31m{0}\033[1;m failed: {1}'.format(127                    tool, error_output))128            count += 1129def uninstall_all(toolist):130    '''131    Uninstall all the tools in toolist132    '''133    count = 1134    length = len(toolist)135    for tool in toolist:136        # Some unsupport package dict.values() return 0137        if tool != 0:138            print(139                '\033[1;36mRemove\033[1;m \033[1;32m{0}    {1}/{2}\033[1;m'.format(tool, count, length))140            try:141                subprocess.check_call(142                    'apt -y autoremove {0}'.format(tool), shell=True)143            except subprocess.CalledProcessError as error_output:144                print('Remove the {0} failed: {1}'.format(145                    tool, error_output))146            count += 1147def every_select(toolswitcher, specialtoolswitcher):148    '''149    Solve repetitive code issues150    '''151    print(152        '\033[1;32mInsert the number of the tool to install it.\n\033[1;m')153    eselect = input('\033[1;36mkat > \033[1;m')154    if eselect == 'back':155        loop()156    elif eselect == 'home':157        loop()158    elif eselect == '0':159        toollist = toolswitcher.values()160        install_all(toollist)161    else:162        try:163            eselectnum = int(eselect)164        except IOError as error_output:165            print('\033[1;31mInvalid command!\033[1;m')166            print('Error: {0]'.format(error_output))167        package_name = toolswitcher.get(168            eselectnum, 'nothing')169        if package_name != 0 and package_name != 'nothing':170            try:171                subprocess.check_call(172                    'apt install {0}'.format(package_name), shell=True)173            except subprocess.CalledProcessError as error_output:174                print('Install \033[1;31m{0}\033[1;m failed: {1}'.format(175                    package_name, error_output))176        elif package_name == 0:177            # Find the install way in specialtoolswitcher178            install_way = specialtoolswitcher.get(179                eselectnum, '\033[1;31mSorry, This package is not supportd\033[1;m'180            )181            print(install_way)182        elif package_name == 'nothing':183            print('\033[1;31mInvalid command!\033[1;m')184def loop_install():185    '''186    Install loop187    '''188    interface.pinstall()189    # 1) Information Gathering            8) Exploitation Tools190    # 2) Vulnerability Analysis           9) Forensics Tools191    # 3) Wireless Attacks                 10) Stress Testing192    # 4) Web Applications                 11) Password Attacks193    # 5) Sniffing & Spoofing              12) Reverse Engineering194    # 6) Maintaining Access               13) Hardware Hacking195    # 7) Reporting Tools                  14) Extra196    # 0) Install all                      r) Remove all197    print(198        '\033[1;32mSelect a category or press (0) to install all Kali tools.\n\033[1;m')199    uselect_2 = input('\033[1;36mkat > \033[1;m')200    if uselect_2 == 'back':201        # loop()202        return203    elif uselect_2 == 'home':204        # loop()205        return206    elif uselect_2 == 'r':207        # Remove all the tools208        # Get the tool dict209        information_dict = toollist.information_gathering()210        vulnerability_dict = toollist.vulnerability_analysis()211        wireless_dict = toollist.wireless_attacks()212        web_dict = toollist.web_applications()213        sniffing_dict = toollist.sniffing_spoofing()214        maintaining_dict = toollist.maintaining_access()215        reporting_dict = toollist.reporting_tools()216        exploitation_dict = toollist.exploitation_tools()217        forensics_dict = toollist.forensics_tools()218        stress_dict = toollist.stress_testing()219        password_dict = toollist.password_attacks()220        reverse_dict = toollist.reverse_engineering()221        hardware_dict = toollist.hardware_hacking()222        extra_dict = toollist.extra()223        # Get the tool list224        information_list = information_dict.values()225        vulnerability_list = vulnerability_dict.values()226        wireless_list = wireless_dict.values()227        web_list = web_dict.values()228        sniffing_list = sniffing_dict.values()229        maintaining_list = maintaining_dict.values()230        reporting_list = reporting_dict.values()231        exploitation_list = exploitation_dict.values()232        forensics_list = forensics_dict.values()233        stress_list = stress_dict.values()234        password_list = password_dict.values()235        reverse_list = reverse_dict.values()236        hardware_list = hardware_dict.values()237        extra_list = extra_dict.values()238        uninstall_all(information_list)239        uninstall_all(vulnerability_list)240        uninstall_all(wireless_list)241        uninstall_all(web_list)242        uninstall_all(sniffing_list)243        uninstall_all(maintaining_list)244        uninstall_all(reporting_list)245        uninstall_all(exploitation_list)246        uninstall_all(forensics_list)247        uninstall_all(stress_list)248        uninstall_all(password_list)249        uninstall_all(reverse_list)250        uninstall_all(hardware_list)251        uninstall_all(extra_list)252    elif uselect_2 == '0':253        # Install all the tools254        # Get the tool dict255        information_dict = toollist.information_gathering()256        vulnerability_dict = toollist.vulnerability_analysis()257        wireless_dict = toollist.wireless_attacks()258        web_dict = toollist.web_applications()259        sniffing_dict = toollist.sniffing_spoofing()260        maintaining_dict = toollist.maintaining_access()261        reporting_dict = toollist.reporting_tools()262        exploitation_dict = toollist.exploitation_tools()263        forensics_dict = toollist.forensics_tools()264        stress_dict = toollist.stress_testing()265        password_dict = toollist.password_attacks()...Install.py
Source:Install.py  
1from collective.flowplayer.uninstall import all as uninstall_all2def uninstall(portal):3    uninstall_all(portal)...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!!
