Best Python code snippet using localstack_python
create_dashboard.py
Source: create_dashboard.py
...36 self.name))37 def remove_dashboard(self):38 if os.path.isfile(self.layout):39 self._remove_file(self.layout)40 def list_dashboards(self):41 if not os.path.isdir(self.layout_dir):42 print('No such directory: {}'.format(self.layout_dir))43 sys.exit(1)44 for d in os.listdir(self.layout_dir):45 layout_path = os.path.join(self.layout_dir, d)46 name, _ = os.path.splitext(os.path.basename(d))47 print('{} {}'.format(name, layout_path))48class DryrunFactory(DashboardFactory):49 def _create_dir(self):50 print('Would create {}'.format(self.dashboard_dir))51 def _write_file(self, file_path):52 print('Would create {}'.format(file_path))53 def _remove_file(self, file_path):54 print('Would remove {}'.format(file_path))55def get_factory(name, dry_run=False):56 return DryrunFactory(name) if dry_run else DashboardFactory(name)57if __name__ == '__main__':58 parser = argparse.ArgumentParser(description='Create a new dashboard.')59 parser.add_argument('-n', '--dry-run', dest='dry_run', action='store_true',60 help=('Show what would be done, but don\'t'61 ' do anything'))62 parser.add_argument('-l', '--list', dest='list_dashboards',63 action='store_true', help='List dashboards')64 parser.add_argument('-r', '--remove', dest='remove', action='store_true',65 help='Remove dashboard')66 parser.add_argument('name', metavar='NAME', nargs='?')67 args = parser.parse_args()68 if args.list_dashboards:69 get_factory('', True).list_dashboards()70 elif args.remove:71 name = args.name or input('Name of the dashboard to remove: ')72 get_factory(name, args.dry_run).remove_dashboard()73 else:74 name = args.name or input('Name of the dashboard to create: ')...
sql.py
Source: sql.py
1import sqlite32def conexao_db():3 conn = sqlite3.connect('db.observatorio')4 cursor = conn.cursor()5 return [conn, cursor]6def get_noticias():7 conn, cursor = conexao_db()8 cursor.execute(f"""SELECT * FROM app_noticias;""")9 noticias = None10 list_noticias = []11 for linha in cursor.fetchall():12 noticias = {13 "id": linha[0],14 "titulo": linha[1],15 "url": linha[2],16 "resumo": linha[3],17 "imagem": linha[4],18 "data": linha[5],19 "publicar": linha[6],20 "autor_id": linha[7],21 "fonte": linha[8],22 }23 list_noticias.append(noticias)24 conn.close()25 if not list_noticias:26 return list_noticias27 return list_noticias28def get_pluviograma():29 conn, cursor = conexao_db()30 cursor.execute(f"""SELECT * FROM app_pluviograma;""")31 pluviograma = None32 list_pluviograma = []33 for linha in cursor.fetchall():34 pluviograma = {35 "id": linha[0],36 "titulo": linha[1],37 "data": linha[2],38 "publicar": linha[3],39 "autor_id": linha[4],40 "imagem_mini_post": linha[5],41 "fonte": linha[6],42 }43 list_pluviograma.append(pluviograma)44 conn.close()45 if not list_pluviograma:46 return list_pluviograma47 return list_pluviograma48def get_dashboard():49 conn, cursor = conexao_db()50 cursor.execute(f"""SELECT * FROM app_dashboard;""")51 dashboards = None52 list_dashboards = []53 for linha in cursor.fetchall():54 dashboards = {55 "id": linha[0],56 "titulo": linha[1],57 "data": linha[2],58 "publicar": linha[3],59 "autor_id": linha[4],60 "imagem_post": linha[5],61 "fonte": linha[6],62 }63 list_dashboards.append(dashboards)64 conn.close()65 if not list_dashboards:66 return list_dashboards...
api.py
Source: api.py
...15 # example passing only required values which don't have defaults set16 # and optional values17 try:18 # Get all dashboards19 api_response = api_instance.list_dashboards(20 filter_shared=filter_shared)21 pprint(api_response)22 except ApiException as e:...
Check out the latest blogs from LambdaTest on this topic:
Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.
Xamarin is an open-source framework that offers cross-platform application development using the C# programming language. It helps to simplify your overall development and management of cross-platform software applications.
The web paradigm has changed considerably over the last few years. Web 2.0, a term coined way back in 1999, was one of the pivotal moments in the history of the Internet. UGC (User Generated Content), ease of use, and interoperability for the end-users were the key pillars of Web 2.0. Consumers who were only consuming content up till now started creating different forms of content (e.g., text, audio, video, etc.).
When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.
Many theoretical descriptions explain the role of the Scrum Master as a vital member of the Scrum team. However, these descriptions do not provide an honest answer to the fundamental question: “What are the day-to-day activities of a Scrum Master?”
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!!