Exemple #1
0
    def build_documentation(self, list_of_contents):

        # Instanciation of the integrations class since it's needed for content management below.
        Int = Integrations(self.options.source, self.tempdir,
                           self.integration_mutations)

        # Depending of the action attached to the content the proper function is called
        for content in list_of_contents:
            try:
                if content["action"] == "integrations":
                    Int.process_integrations(content)
                elif content["action"] == "marketplace-integrations":
                    Int.process_integrations(content, marketplace=True)
                elif (content["action"] == "pull-and-push-folder"):
                    pull_and_push_folder(content, self.content_dir)
                elif content["action"] == "npm-integrations":
                    Int.process_integrations(content)
                elif content["action"] == "pull-and-push-file":
                    pull_and_push_file(content, self.content_dir)
                elif content["action"] in ("security-rules",
                                           "compliance-rules"):
                    security_rules(content, self.content_dir)
                elif content["action"] == "Not Available":
                    if getenv("LOCAL") == 'True':
                        print(
                            "\x1b[33mWARNING\x1b[0m: Processing of {} canceled, since content is not available. Documentation is in degraded mode"
                            .format(content["repo_name"]))
                else:
                    print("\x1b[31mERROR\x1b[0m: Action {} unknown for {}".
                          format(content["action"], content))
                    raise ValueError
            except Exception as e:
                print(e)
                if getenv("LOCAL") == 'True':
                    print(
                        "\x1b[33mWARNING\x1b[0m: Unsuccessful processing of {}"
                        .format(content))
                else:
                    print(
                        "\x1b[31mERROR\x1b[0m: Unsuccessful processing of {}".
                        format(content))
                    raise ValueError

        # Once all the content is processed integrations are merged according to the integration_merge.yaml
        # configuration file. This needs to happen after all content is processed to avoid flacky integration merge
        try:
            Int.merge_integrations()
        except Exception as e:
            print(e)
            if getenv("LOCAL") == 'True':
                print(
                    "\x1b[33mWARNING\x1b[0m: Integration merge failed, documentation is now in degraded mode."
                )
            else:
                print(
                    "\x1b[31mERROR\x1b[0m: Integration merge failed, stopping build."
                )
                sys.exit(1)
Exemple #2
0
def _add_integration():
    #TODO - three fields, company_name, website, domain
    # - really only need 1 
    token = request.args["token"]
    user = request.args["user"]
    user_company = request.args["user_company"]

    print request.args
    print token, user, user_company, request.args["source"]
    if "google" in request.args["source"]:
      q.enqueue(Integrations()._google_contact_import, token, user, user_company)
    elif "salesforce" in request.args["source"]:
      print "SALESFORCE"
      instance_url = request.args["instance_url"]
      q.enqueue(Integrations()._salesforce_import, token, instance_url, 
                user, user_company)
    return {"started":True}
Exemple #3
0
    def __init__(self, username=None, password=None):
        self.general = General(self)
        self.model = Model(self)
        self.actions = Actions(self)
        self.groups = Groups(self)
        self.customers = Customers(self)
        self.segments = Segments(self)
        self.integrations = Integrations(self)

        if username and password:
            self.general.login(username, password)
Exemple #4
0
    def test_image_src_replaced_by_shortcode(self):
      markdown_img_search_regex = r"!\[(.*?)\]\((.*?)\)"
      img_shortcode_regex = r"({{2}< img)(.*)(>}{2})"
      test_markdown_string = ("## Test\n\n"
        "![TestScreenshot](/fake/path/to/images/1.png)\n\n"
        "### EndTest")

      result = Integrations.replace_image_src(test_markdown_string)

      self.assertNotRegex(result, markdown_img_search_regex)
      self.assertRegex(result, img_shortcode_regex)
Exemple #5
0
    def test_section_removed_from_markdown(self):
      header_string = '## Setup'
      test_markdown_string = ("This is a test markdown string\n\n"
        "## Setup\n\n"
        "1. This\n"
        "2. and this\n"
        "3. should be removed\n\n"
        "### This too\n\n"
        "## This should not be removed")

      result = Integrations.remove_markdown_section(test_markdown_string, header_string)

      self.assertNotIn(header_string, result)
      self.assertIn('## This should not be removed', result)
Exemple #6
0
    def __init__(self,
                 username=None,
                 password=None,
                 timeout=TIMEOUT,
                 url=DEFAULT_URL):
        self.general = General(self)
        self.model = Model(self)
        self.actions = Actions(self)
        self.groups = Groups(self)
        self.customers = Customers(self)
        self.segments = Segments(self)
        self.integrations = Integrations(self)
        self.timeout = timeout
        self._url = url

        if username and password:
            self.general.login(username, password)