diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/cirrus/lib.sh | 13 | ||||
-rwxr-xr-x | contrib/cirrus/podbot.py | 98 | ||||
-rwxr-xr-x | contrib/cirrus/success.sh | 22 | ||||
-rw-r--r-- | contrib/python/podman/MANIFEST.in | 1 | ||||
-rwxr-xr-x | contrib/python/podman/test/test_runner.sh | 12 | ||||
-rw-r--r-- | contrib/python/podman/tox.ini | 8 | ||||
-rw-r--r-- | contrib/python/pypodman/pypodman/lib/actions/pod/processes_parser.py | 4 | ||||
-rw-r--r-- | contrib/python/pypodman/pypodman/lib/podman_parser.py | 4 |
8 files changed, 146 insertions, 16 deletions
diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh index c6cac44ec..1e0052a65 100644 --- a/contrib/cirrus/lib.sh +++ b/contrib/cirrus/lib.sh @@ -96,6 +96,19 @@ stub() { echo "STUB: Pretending to do $1" } +ircmsg() { + req_env_var " + SCRIPT_BASE $SCRIPT_BASE + GOSRC $GOSRC + CIRRUS_TASK_ID $CIRRUS_TASK_ID + 1 $1 + " + SCRIPT="$GOSRC/$SCRIPT_BASE/podbot.py" + NICK="podbot_$CIRRUS_TASK_ID" + NICK="${NICK:0:15}" # Any longer will break things + $SCRIPT $NICK $1 +} + # Run sudo in directory with GOPATH set cdsudo() { DIR="$1" diff --git a/contrib/cirrus/podbot.py b/contrib/cirrus/podbot.py new file mode 100755 index 000000000..1be41a8ed --- /dev/null +++ b/contrib/cirrus/podbot.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python3 + +# Simple and dumb script to send a message to the #podman IRC channel on frenode +# Based on example from: https://pythonspot.com/building-an-irc-bot/ + +import os +import time +import random +import errno +import socket +import sys + +class IRC: + + response_timeout = 10 # seconds + irc = socket.socket() + + def __init__(self, server, nickname, channel): + self.server = server + self.nickname = nickname + self.channel = channel + self.irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + def _send(self, cmdstr): + self.irc.send(bytes(cmdstr + '\r\n', 'utf-8')) + + def message(self, msg): + data = 'PRIVMSG {0} :{1}\r\n'.format(self.channel, msg) + print(data) + self._send(data) + + @staticmethod + def fix_newlines(bufr): + return bufr.replace('\\r\\n', '\n') + + def _required_response(self, needle, haystack): + start = time.time() + end = start + self.response_timeout + while time.time() < end: + if haystack.find(needle) != -1: + return (False, haystack) + time.sleep(0.1) + try: + haystack += str(self.irc.recv(4096, socket.MSG_DONTWAIT)) + except socket.error as serr: + if serr.errno == errno.EWOULDBLOCK: + continue + raise # can't handle this + return (True, haystack) # Error + + def connect(self, username, password): + # This is ugly as sin, but seems to be a working send/expect sequence + + print("connecting to: {0}".format(self.server)) + self.irc.connect((self.server, 6667)) #connects to the server + self._send("USER {0} {0} {0} :I am {0}".format(self.nickname)) + self._send("NICK {0}".format(self.nickname)) + + err, haystack = self._required_response('End of /MOTD command.' + ''.format(self.nickname), "") + if err: + print(self.fix_newlines(haystack)) + print("Error connecting to {0}".format(self.server)) + return True + + print("Logging in as {0}".format(username)) + self._send("PRIVMSG NickServ :IDENTIFY {0} {1}".format(username, password)) + err, _ = self._required_response("You are now identified for", "") + if err: + print("Error logging in to {0} as {1}".format(self.server, username)) + return True + + print("Joining {0}".format(self.channel)) + self._send("JOIN {0}".format(self.channel)) + err, haystack = self._required_response("{0} {1} :End of /NAMES list." + "".format(self.nickname, self.channel), + haystack) + print(self.fix_newlines(haystack)) + if err: + print("Error joining {0}".format(self.channel)) + return True + return False + + def quit(self): + print("Quitting") + self._send("QUIT :my work is done here") + self.irc.close() + + +if len(sys.argv) < 3: + print("Error: Must pass desired nick and message as parameters") +else: + irc = IRC("irc.freenode.net", sys.argv[1], "#podman") + err = irc.connect(*os.environ.get('IRCID', 'Big Bug').split(" ", 2)) + if not err: + irc.message(" ".join(sys.argv[2:])) + time.sleep(5.0) # avoid join/quit spam + irc.quit() diff --git a/contrib/cirrus/success.sh b/contrib/cirrus/success.sh new file mode 100755 index 000000000..d1daf9043 --- /dev/null +++ b/contrib/cirrus/success.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e +source $(dirname $0)/lib.sh + +req_env_var " + CIRRUS_TASK_NAME $CIRRUS_TASK_NAME + CIRRUS_BRANCH $CIRRUS_BRANCH + OS_RELEASE_ID $OS_RELEASE_ID + OS_RELEASE_VER $OS_RELEASE_VER + CIRRUS_REPO_CLONE_URL $CIRRUS_REPO_CLONE_URL +" + +REF_URL="$(echo $CIRRUS_REPO_CLONE_URL | sed 's/.git$//g')" +if [[ "$CIRRUS_BRANCH" =~ "pull" ]] +then + REF_URL="$REF_URL/$CIRRUS_BRANCH" # pull request URL +else + REF_URL="$REF_URL/commits/$CIRRUS_BRANCH" # branch merge +fi + +ircmsg "Cirrus-CI $CIRRUS_TASK_NAME on $OS_RELEASE_ID-$OS_RELEASE_VER successful for $REF_URL" diff --git a/contrib/python/podman/MANIFEST.in b/contrib/python/podman/MANIFEST.in index 72e638cb9..a5897de50 100644 --- a/contrib/python/podman/MANIFEST.in +++ b/contrib/python/podman/MANIFEST.in @@ -1,2 +1,3 @@ prune test/ include README.md +include requirements.txt diff --git a/contrib/python/podman/test/test_runner.sh b/contrib/python/podman/test/test_runner.sh index 081b90779..65cbd1e9c 100755 --- a/contrib/python/podman/test/test_runner.sh +++ b/contrib/python/podman/test/test_runner.sh @@ -143,18 +143,6 @@ else RETURNCODE=$? fi -if [[ "$RETURNCODE" -ne 0 ]] && [[ -n "$FLAKE_DEBUG_DELAY" ]] -then - cat << EOF > /dev/stderr -***** -***** WARNING: \$FLAKE_DEBUG_DELAY IS SET AND PYTHON-PODMAN TESTS EXITED: $RETURNCODE -***** WARNING: Sleeping for 30 minutes for test-VM preservation oportunity. -***** -EOF - sleep 30m -fi - - pkill -9 podman pkill -9 conmon diff --git a/contrib/python/podman/tox.ini b/contrib/python/podman/tox.ini new file mode 100644 index 000000000..797eafbe3 --- /dev/null +++ b/contrib/python/podman/tox.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py34,py35,py36 +skipdist = True + +[testenv] +deps=-rrequirements.txt +whitelist_externals = bash +commands=bash test/test_runner.sh diff --git a/contrib/python/pypodman/pypodman/lib/actions/pod/processes_parser.py b/contrib/python/pypodman/pypodman/lib/actions/pod/processes_parser.py index 411a6d5a3..ecfcb883a 100644 --- a/contrib/python/pypodman/pypodman/lib/actions/pod/processes_parser.py +++ b/contrib/python/pypodman/pypodman/lib/actions/pod/processes_parser.py @@ -10,7 +10,7 @@ class ProcessesPod(AbstractActionBase): @classmethod def subparser(cls, parent): - """Add Images command to parent parser.""" + """Add Pod Ps command to parent parser.""" parser = parent.add_parser('ps', help='list processes of pod') super().subparser(parser) @@ -40,7 +40,7 @@ class ProcessesPod(AbstractActionBase): parser.set_defaults(class_=cls, method='processes') def __init__(self, args): - """Contstruct ProcessesPod class.""" + """Construct ProcessesPod class.""" if args.sort == 'created': args.sort = 'createdat' elif args.sort == 'count': diff --git a/contrib/python/pypodman/pypodman/lib/podman_parser.py b/contrib/python/pypodman/pypodman/lib/podman_parser.py index 1ba9bb7fc..d3c84224f 100644 --- a/contrib/python/pypodman/pypodman/lib/podman_parser.py +++ b/contrib/python/pypodman/pypodman/lib/podman_parser.py @@ -154,7 +154,7 @@ class PodmanArgumentParser(argparse.ArgumentParser): getattr(args, 'run_dir') or os.environ.get('RUN_DIR') or config['default'].get('run_dir') - or Path(args.xdg_runtime_dir, 'pypodman') + or str(Path(args.xdg_runtime_dir, 'pypodman')) ) # yapf: disable setattr( @@ -211,7 +211,7 @@ class PodmanArgumentParser(argparse.ArgumentParser): args.identity_file = None if args.host: - args.local_socket_path = Path(args.run_dir, 'podman.socket') + args.local_socket_path = str(Path(args.run_dir, 'podman.socket')) else: args.local_socket_path = args.remote_socket_path |