Пример #1
0
def main():
    # Get subdomain.
    try:
        cloudfront_url = os.environ["ZENDESK_CLOUDFRONT_URL"]
    except KeyError:
        print(Fore.RED +
              "Please set the environment variable ZENDESK_CLOUDFRONT_URL" +
              Fore.RESET)
        sys.exit(1)

    # Get subdomain.
    try:
        subdomain = os.environ["ZENDESK_SUBDOMAIN"]
        zendesk_url = file_constants.get_url_from_subdomain(subdomain)
    except KeyError:
        print(Fore.RED +
              "Please set the environment variable ZENDESK_SUBDOMAIN" +
              Fore.RESET)
        sys.exit(1)

    # Get username.
    try:
        username = os.environ["ZENDESK_USR"]
    except KeyError:
        print(Fore.RED + "Please set the environment variable ZENDESK_USR" +
              Fore.RESET)
        sys.exit(1)

    # Get password.
    try:
        password = os.environ["ZENDESK_PWD"]
    except KeyError:
        print(Fore.RED + "Please set the environment variable ZENDESK_PWD" +
              Fore.RESET)
        sys.exit(1)

    # Check for articles that were posted directly on Zendesk instead of locally.

    compare_repos.compare_article_ids(zendesk_url, username, password)

    if len(sys.argv) == 2:
        print(Fore.MAGENTA + "Processing Article 1/1" + Fore.RESET)
        _deploy(sys.argv[1], zendesk_url, cloudfront_url, username, password)
    else:
        article_ids = next(os.walk("posts"))[1]
        i = 1
        for article_id in article_ids:
            print(
                Fore.MAGENTA + "Processing Article %s/%s %s" %
                (str(i), len(article_ids), article_id) + Fore.RESET)
            _deploy(article_id, zendesk_url, cloudfront_url, username,
                    password)
            i += 1

    print "=" * 40
    print(Fore.GREEN + "SUCCESSFULLY FINISHED DEPLOYMENT" + Fore.RESET)
Пример #2
0
def main():
    # Get subdomain.
    try:
        cloudfront_url = os.environ["ZENDESK_CLOUDFRONT_URL"]
    except KeyError:
        print(Fore.RED + "Please set the environment variable ZENDESK_CLOUDFRONT_URL" + Fore.RESET)
        sys.exit(1)

    # Get subdomain.
    try:
        subdomain = os.environ["ZENDESK_SUBDOMAIN"]
        zendesk_url = file_constants.get_url_from_subdomain(subdomain)
    except KeyError:
        print(Fore.RED + "Please set the environment variable ZENDESK_SUBDOMAIN" + Fore.RESET)
        sys.exit(1)

    # Get username.
    try:
        username = os.environ["ZENDESK_USR"]
    except KeyError:
        print(Fore.RED + "Please set the environment variable ZENDESK_USR" + Fore.RESET)
        sys.exit(1)

    # Get password.
    try:
        password = os.environ["ZENDESK_PWD"]
    except KeyError:
        print(Fore.RED + "Please set the environment variable ZENDESK_PWD" + Fore.RESET)
        sys.exit(1)

    # Check for articles that were posted directly on Zendesk instead of locally.

    compare_repos.compare_article_ids(zendesk_url, username, password)

    if len(sys.argv) == 2:
        print (Fore.MAGENTA + "Processing Article 1/1" + Fore.RESET)
        _deploy(sys.argv[1], zendesk_url, cloudfront_url, username, password)
    else:
        article_ids = next(os.walk("posts"))[1]
        i = 1
        for article_id in article_ids:
            print (Fore.MAGENTA + "Processing Article %s/%s %s" % (str(i), len(article_ids), article_id) + Fore.RESET)
            _deploy(article_id, zendesk_url, cloudfront_url, username, password)
            i += 1

    print "="*40
    print(Fore.GREEN + "SUCCESSFULLY FINISHED DEPLOYMENT" + Fore.RESET)
Пример #3
0
def _create_shell(section_id):

    # Get subdomain.
    try:
        subdomain = os.environ["ZENDESK_SUBDOMAIN"]
        url = file_constants.get_url_from_subdomain(subdomain)
    except KeyError:
        print(Fore.RED +
              "Please set the environment variable ZENDESK_SUBDOMAIN" +
              Fore.RESET)
        sys.exit(1)

    # Get username.
    try:
        username = os.environ["ZENDESK_USR"]
    except KeyError:
        print(Fore.RED + "Please set the environment variable ZENDESK_USR" +
              Fore.RESET)
        sys.exit(1)

    # Get password.
    try:
        password = os.environ["ZENDESK_PWD"]
    except KeyError:
        print(Fore.RED + "Please set the environment variable ZENDESK_PWD" +
              Fore.RESET)
        sys.exit(1)

    zendesk = Zendesk(url, username, password)

    # Add a temporary title and leave it in draft mode.
    new_article = {"article": {"title": "Temporary Title", "draft": True}}

    response = zendesk.help_center_section_article_create(id=section_id,
                                                          data=new_article)

    # Report success.
    print('Successfully created the article.')

    # Create the article shell locally.
    article_id = response['article']['id']
    _empty_article(str(article_id))
def _create_shell(section_id):

    # Get subdomain.
    try:
        subdomain = os.environ["ZENDESK_SUBDOMAIN"]
        url = file_constants.get_url_from_subdomain(subdomain)
    except KeyError:
        print(Fore.RED + "Please set the environment variable ZENDESK_SUBDOMAIN" + Fore.RESET)
        sys.exit(1)

    # Get username.
    try:
        username = os.environ["ZENDESK_USR"]
    except KeyError:
        print(Fore.RED + "Please set the environment variable ZENDESK_USR" + Fore.RESET)
        sys.exit(1)

    # Get password.
    try:
        password = os.environ["ZENDESK_PWD"]
    except KeyError:
        print(Fore.RED + "Please set the environment variable ZENDESK_PWD" + Fore.RESET)
        sys.exit(1)

    zendesk = Zendesk(url, username, password)

    # Add a temporary title and leave it in draft mode.
    new_article = {"article": {"title": "Temporary Title", "draft": True}}

    response = zendesk.help_center_section_article_create(id = section_id, data = new_article)

    # Report success.
    print('Successfully created the article.')

    # Create the article shell locally.
    article_id = response['article']['id']
    _empty_article(str(article_id))