Example #1
0
	def run(self):
		# If no e-mail recipients are configured, no need to continue. So ...
		if not self._config.get('mailinglist'):
			# ... either configure mailinglist ...
			if not self._config.get('refchangelist') or not config.get('commitlist'):
				# ... or both refchangelist and commitlist.
				return

		mailer = git_multimail.choose_mailer(self._config, self)
		git_multimail.run_as_post_receive_hook(self, mailer)
def main(args):

    # Specify which "git config" section contains the configuration for
    # git-multimail:
    config = Config('multimailhook')

    # GitHub API
    githubtoken = os.getenv("GITHUB_ACCESS_TOKEN")
    if not githubtoken:
        githubtoken = config.get("githubAccessToken")
    if not githubtoken:
        sys.stderr.write(
            "Set GITHUB_ACCESS_TOKEN in environment or " +
            "'git config multimailhook.githubAccessToken <token>'!\n")
        sys.exit(1)

    # Trac Environment
    tracenvpath = os.getenv("TRAC_ENV")
    if not tracenvpath:
        tracenvpath = config.get("tracEnv")
    if not tracenvpath:
        sys.stderr.write("Set TRAC_ENV in environment or " +
                         "'git config multimailhook.tracEnv <path>'!\n")
        sys.exit(1)

    # Select the type of environment:
    try:
        environment = GitHubWebhookEnvironment(githubtoken,
                                               tracenvpath,
                                               config=config)
    except ConfigurationException:
        sys.stderr.write("%s\n" % sys.exc_info()[1])
        sys.exit(1)

    # Choose the method of sending emails based on the git config:
    mailer = git_multimail.choose_mailer(config, environment)

    if "-n" in args:
        # OutputMailer is intended only for testing; it writes the emails to
        # the specified file stream.
        mailer = OutputMailer(sys.stdout)

    # Send notification emails:
    run_as_github_webhook(environment, mailer)

    sys.exit(0)
import git_multimail


# It is possible to modify the output templates here; e.g.:

git_multimail.FOOTER_TEMPLATE = """\

-- \n\
This email was generated by the wonderful git-multimail tool from JBox Web.
"""


# Specify which "git config" section contains the configuration for
# git-multimail:
config = git_multimail.Config('multimailhook')

# check if hook is enabled
enabled = config.get_bool('enabled')

if enabled:
  # Select the type of environment:
  environment = git_multimail.GitoliteEnvironment(config=config)

  # Choose the method of sending emails based on the git config:
  mailer = git_multimail.choose_mailer(config, environment)

  # Read changes from stdin and send notification emails:
  git_multimail.run_as_post_receive_hook(environment, mailer)
else:
  print "    multimailhook is disabled"
import os

import git_multimail

# It is possible to modify the output templates here; e.g.:

git_multimail.FOOTER_TEMPLATE = """\

-- \n\
This email was generated by the wonderful git-multimail tool from JBox Web.
"""

# Specify which "git config" section contains the configuration for
# git-multimail:
config = git_multimail.Config('multimailhook')

# check if hook is enabled
enabled = config.get_bool('enabled')

if enabled:
    # Select the type of environment:
    environment = git_multimail.GitoliteEnvironment(config=config)

    # Choose the method of sending emails based on the git config:
    mailer = git_multimail.choose_mailer(config, environment)

    # Read changes from stdin and send notification emails:
    git_multimail.run_as_post_receive_hook(environment, mailer)
else:
    print "    multimailhook is disabled"