black: Reformat skipping string normalization.
This commit is contained in:
parent
5580c68ae5
commit
fba21bb00d
178 changed files with 6562 additions and 4469 deletions
|
@ -21,7 +21,9 @@ client = zulip.Client(
|
|||
email=config.ZULIP_USER,
|
||||
site=config.ZULIP_SITE,
|
||||
api_key=config.ZULIP_API_KEY,
|
||||
client='ZulipOpenShift/' + VERSION)
|
||||
client='ZulipOpenShift/' + VERSION,
|
||||
)
|
||||
|
||||
|
||||
def get_deployment_details() -> Dict[str, str]:
|
||||
# "gear deployments" output example:
|
||||
|
@ -30,10 +32,13 @@ def get_deployment_details() -> Dict[str, str]:
|
|||
dep = subprocess.check_output(['gear', 'deployments'], universal_newlines=True).splitlines()[1]
|
||||
splits = dep.split(' - ')
|
||||
|
||||
return dict(app_name=os.environ['OPENSHIFT_APP_NAME'],
|
||||
url=os.environ['OPENSHIFT_APP_DNS'],
|
||||
branch=splits[2],
|
||||
commit_id=splits[3])
|
||||
return dict(
|
||||
app_name=os.environ['OPENSHIFT_APP_NAME'],
|
||||
url=os.environ['OPENSHIFT_APP_DNS'],
|
||||
branch=splits[2],
|
||||
commit_id=splits[3],
|
||||
)
|
||||
|
||||
|
||||
def send_bot_message(deployment: Dict[str, str]) -> None:
|
||||
destination = config.deployment_notice_destination(deployment['branch'])
|
||||
|
@ -42,14 +47,17 @@ def send_bot_message(deployment: Dict[str, str]) -> None:
|
|||
return
|
||||
message = config.format_deployment_message(**deployment)
|
||||
|
||||
client.send_message({
|
||||
'type': 'stream',
|
||||
'to': destination['stream'],
|
||||
'subject': destination['subject'],
|
||||
'content': message,
|
||||
})
|
||||
client.send_message(
|
||||
{
|
||||
'type': 'stream',
|
||||
'to': destination['stream'],
|
||||
'subject': destination['subject'],
|
||||
'content': message,
|
||||
}
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
|
||||
deployment = get_deployment_details()
|
||||
send_bot_message(deployment)
|
||||
|
|
|
@ -21,12 +21,12 @@ ZULIP_API_KEY = '0123456789abcdef0123456789abcdef'
|
|||
# And similarly for branch "test-post-receive" (for use when testing).
|
||||
def deployment_notice_destination(branch: str) -> Optional[Dict[str, Text]]:
|
||||
if branch in ['master', 'test-post-receive']:
|
||||
return dict(stream = 'deployments',
|
||||
subject = '%s' % (branch,))
|
||||
return dict(stream='deployments', subject='%s' % (branch,))
|
||||
|
||||
# Return None for cases where you don't want a notice sent
|
||||
return None
|
||||
|
||||
|
||||
# Modify this function to change how deployments are displayed
|
||||
#
|
||||
# It takes the following arguments:
|
||||
|
@ -39,9 +39,15 @@ def deployment_notice_destination(branch: str) -> Optional[Dict[str, Text]]:
|
|||
# * dep_id = deployment id
|
||||
# * dep_time = deployment timestamp
|
||||
def format_deployment_message(
|
||||
app_name: str = '', url: str = '', branch: str = '', commit_id: str = '', dep_id: str = '', dep_time: str = '') -> str:
|
||||
return 'Deployed commit `%s` (%s) in [%s](%s)' % (
|
||||
commit_id, branch, app_name, url)
|
||||
app_name: str = '',
|
||||
url: str = '',
|
||||
branch: str = '',
|
||||
commit_id: str = '',
|
||||
dep_id: str = '',
|
||||
dep_time: str = '',
|
||||
) -> str:
|
||||
return 'Deployed commit `%s` (%s) in [%s](%s)' % (commit_id, branch, app_name, url)
|
||||
|
||||
|
||||
## If properly installed, the Zulip API should be in your import
|
||||
## path, but if not, set a custom path below
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue