Ejemplo n.º 1
0
    def test_default(self):
        graph_name = 'graph_XKW'    # (7 nodes)
        graph_name = 'graph_MKF'    # ( 20 nodes,  27 edges)
        graph_name = 'graph_YT4'   # (199 nodes, 236 edges)
        #graph_name = 'graph_VZ5'   # (367 nodes, 653 edges)
        #graph_name = 'graph_EE3'    # fails in lamnda

        self.png_data = Vis_Js_Views.default(params=[graph_name])
        return

        browser_helper = Browser_Lamdba_Helper(headless=False).setup()
        pngData = browser_helper.get_screenshot_png(close_browser=False)
        browser_helper.save_png_data(pngData)
 def screenshot(team_id=None, channel=None, params=[]):
     url = params.pop(0).replace('<', '').replace(
         '>', '')  # fix extra chars added by Slack
     delay = Misc.to_int(Misc.array_pop(params, 0))
     slack_message(
         ":point_right: taking screenshot of url: {0}".format(url), [],
         channel, team_id)
     browser_helper = Browser_Lamdba_Helper().setup()
     png_data = browser_helper.get_screenshot_png(url,
                                                  full_page=True,
                                                  delay=delay)
     return browser_helper.send_png_data_to_slack(team_id, channel, url,
                                                  png_data)
Ejemplo n.º 3
0
 def send_screenshot_to_slack(self,
                              team_id=None,
                              channel=None,
                              with_diffs=False):
     png_file = self.create_dashboard_screenshot(with_diffs)
     return Browser_Lamdba_Helper().send_png_file_to_slack(
         team_id, channel, 'risk dashboard', png_file)
    def elk(team_id=None, channel=None, params=None):
        load_dependency('syncer')
        from browser.sites.Site_ELK import ELK_Commands
        from browser.sites.Site_ELK import Site_ELK

        if len(params) == 0:
            Slack_Commands_Helper(ELK_Commands).invoke(team_id, channel,
                                                       params)
            return None

        browser_helper = Browser_Lamdba_Helper().setup()
        elk = Site_ELK(browser_helper.api_browser, team_id, channel)

        elk.sync__connect_and_login()

        params.append(browser_helper)
        params.append(elk)

        result = Slack_Commands_Helper(ELK_Commands).invoke(
            team_id, channel, params)

        if team_id:
            return None
        else:
            return result
    def markdown(team_id, channel, params):
        path = 'examples/markdown.html'
        js_code = {
            'name':
            'convert',
            'params':
            '# Markdown code!!! \n 123 \n - bullet point \n - another one ![](http://visjs.org/images/gettingstartedSlide.png)'
        }
        if params and len(params) > 0:
            js_code['params'] = ' '.join(params).replace('```', '')

        return Browser_Lamdba_Helper().setup()                                   \
                                      .render_file(team_id, channel, path,js_code)
    def test_create_dashboard_with_scores(self):
        scores = {
            'r1_1': 1,
            'r2_1': 2,
            'r3_1': 3,
            'r4_1': None,
            'r5_1': 5,
            'r6_1': 6,
            'r1_2': 4,
            'r2_2': 5,
            'r3_2': 6,
            'r4_2': None,
            'r5_2': 2,
            'r6_2': 7,
            'r1_3': 7,
            'r2_3': 8,
            'r3_3': 9,
            'r4_3': None,
            'r5_3': 3,
            'r6_3': 8,
            'r2_4': None,
            'r3_4': None,
            'r4_4': None,
            'r5_4': 4,
            'r6_4': 9,
            'r2_5': None,
            'r3_5': None,
            'r4_5': None,
            'r5_5': 5,
            'r3_6': None,
            'r4_6': None,
        }

        self.risk_dashboard.create_dashboard_with_scores(scores)
        png_data = self.risk_dashboard.send_screenshot_to_slack()
        Browser_Lamdba_Helper().save_png_data(png_data)
    def render(team_id, channel, params):

        if params:
            target = params.pop(0)
            delay = Misc.to_int(Misc.array_pop(params, 0))
            if len(params) == 4:
                clip = {
                    'x': int(params[0]),
                    'y': int(params[1]),
                    'width': int(params[2]),
                    'height': int(params[3])
                }
            else:
                clip = None
        else:
            return None

        slack_message(":point_right: rendering file `{0}`".format(target), [],
                      channel, team_id)
        return Browser_Lamdba_Helper().setup().render_file(team_id,
                                                           channel,
                                                           target,
                                                           clip=clip,
                                                           delay=delay)
 def test_create_dashboard_with_test_data(self):
     result = self.risk_dashboard.create_dashboard_with_test_data()
     png_data = self.risk_dashboard.send_screenshot_to_slack()
     result = Browser_Lamdba_Helper().save_png_data(png_data)
     Dev.pprint(result)
 def tearDown(self):
     if self.png_data:
         Browser_Lamdba_Helper().save_png_data(self.png_data)
Ejemplo n.º 10
0
 def tearDown(self):
     if self.png_data:
         Browser_Lamdba_Helper(headless=False).save_png_data(self.png_data)
Ejemplo n.º 11
0
 def send_screenshot_to_slack(self, team_id=None, channel=None):
     png_file = self.create_dashboard_screenshot()
     return Browser_Lamdba_Helper().send_png_file_to_slack(
         team_id, channel, self.title, png_file)
Ejemplo n.º 12
0
 def send_screenshot_to_slack(self, team_id, channel):
     png_file = self.create_dashboard_screenshot()
     return Browser_Lamdba_Helper().send_png_file_to_slack(
         team_id, channel, 'risk dashboard', png_file)
Ejemplo n.º 13
0
 def tearDown(self):
     png_data = self.browser.sync__screenshot_base64()
     Browser_Lamdba_Helper().save_png_data(png_data)