From f416289a85c9e55fffb6f84bd85b7298733737db Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Fri, 1 May 2015 18:21:30 -0400 Subject: [PATCH 1/2] update all python with boilerplate --- build/json-extractor.py | 2 +- .../trusty/kubernetes-master/hooks/__init__.py | 16 ++++++++++++++++ .../trusty/kubernetes-master/hooks/hooks.py | 17 ++++++++++++++++- .../trusty/kubernetes-master/hooks/install.py | 16 +++++++++++++++- .../hooks/kubernetes_installer.py | 16 ++++++++++++++++ .../trusty/kubernetes-master/hooks/setup.py | 16 ++++++++++++++++ .../unit_tests/kubernetes_installer_test.py | 16 ++++++++++++++++ .../unit_tests/test_install.py | 16 ++++++++++++++++ .../charms/trusty/kubernetes/hooks/hooks.py | 17 ++++++++++++++++- .../kubernetes/hooks/kubernetes_installer.py | 16 ++++++++++++++++ .../trusty/kubernetes/hooks/lib/__init__.py | 16 ++++++++++++++++ .../trusty/kubernetes/hooks/lib/registrator.py | 16 ++++++++++++++++ .../unit_tests/lib/test_registrator.py | 16 ++++++++++++++++ .../trusty/kubernetes/unit_tests/test_hooks.py | 16 ++++++++++++++++ cluster/juju/return-node-ips.py | 15 +++++++++++++++ .../saltbase/salt/_states/container_bridge.py | 4 +++- .../celery-app-add/celery_conf.py | 16 ++++++++++++++++ .../celery-rabbitmq/celery-app-add/run_tasks.py | 16 ++++++++++++++++ 18 files changed, 258 insertions(+), 5 deletions(-) mode change 100755 => 100644 cluster/juju/charms/trusty/kubernetes-master/hooks/hooks.py mode change 100755 => 100644 cluster/juju/charms/trusty/kubernetes-master/hooks/install.py mode change 100755 => 100644 cluster/juju/charms/trusty/kubernetes/hooks/hooks.py mode change 100755 => 100644 cluster/juju/return-node-ips.py diff --git a/build/json-extractor.py b/build/json-extractor.py index e8b62f59102..67b4f7a9df1 100755 --- a/build/json-extractor.py +++ b/build/json-extractor.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2014 Google Inc. All rights reserved. +# Copyright 2014 The Kubernetes Authors All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/cluster/juju/charms/trusty/kubernetes-master/hooks/__init__.py b/cluster/juju/charms/trusty/kubernetes-master/hooks/__init__.py index e69de29bb2d..8eefd60722b 100644 --- a/cluster/juju/charms/trusty/kubernetes-master/hooks/__init__.py +++ b/cluster/juju/charms/trusty/kubernetes-master/hooks/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/cluster/juju/charms/trusty/kubernetes-master/hooks/hooks.py b/cluster/juju/charms/trusty/kubernetes-master/hooks/hooks.py old mode 100755 new mode 100644 index 9550a3aa07d..238f451216e --- a/cluster/juju/charms/trusty/kubernetes-master/hooks/hooks.py +++ b/cluster/juju/charms/trusty/kubernetes-master/hooks/hooks.py @@ -1,4 +1,19 @@ -#!/usr/bin/python +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """ The main hook file is called by Juju. """ diff --git a/cluster/juju/charms/trusty/kubernetes-master/hooks/install.py b/cluster/juju/charms/trusty/kubernetes-master/hooks/install.py old mode 100755 new mode 100644 index 8f4384aa1c1..6376ee09a57 --- a/cluster/juju/charms/trusty/kubernetes-master/hooks/install.py +++ b/cluster/juju/charms/trusty/kubernetes-master/hooks/install.py @@ -1,4 +1,18 @@ -#!/usr/bin/python +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import setup setup.pre_install() diff --git a/cluster/juju/charms/trusty/kubernetes-master/hooks/kubernetes_installer.py b/cluster/juju/charms/trusty/kubernetes-master/hooks/kubernetes_installer.py index 9a6123a72e4..777699140a4 100644 --- a/cluster/juju/charms/trusty/kubernetes-master/hooks/kubernetes_installer.py +++ b/cluster/juju/charms/trusty/kubernetes-master/hooks/kubernetes_installer.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os import shlex import subprocess diff --git a/cluster/juju/charms/trusty/kubernetes-master/hooks/setup.py b/cluster/juju/charms/trusty/kubernetes-master/hooks/setup.py index 0c6efbffbb2..84b757ce3ad 100644 --- a/cluster/juju/charms/trusty/kubernetes-master/hooks/setup.py +++ b/cluster/juju/charms/trusty/kubernetes-master/hooks/setup.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + def pre_install(): """ Do any setup required before the install hook. diff --git a/cluster/juju/charms/trusty/kubernetes-master/unit_tests/kubernetes_installer_test.py b/cluster/juju/charms/trusty/kubernetes-master/unit_tests/kubernetes_installer_test.py index ba0367863fd..020ec401051 100644 --- a/cluster/juju/charms/trusty/kubernetes-master/unit_tests/kubernetes_installer_test.py +++ b/cluster/juju/charms/trusty/kubernetes-master/unit_tests/kubernetes_installer_test.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from mock import patch from path import path from path import Path diff --git a/cluster/juju/charms/trusty/kubernetes-master/unit_tests/test_install.py b/cluster/juju/charms/trusty/kubernetes-master/unit_tests/test_install.py index e6fe3d08e89..b34748a6766 100644 --- a/cluster/juju/charms/trusty/kubernetes-master/unit_tests/test_install.py +++ b/cluster/juju/charms/trusty/kubernetes-master/unit_tests/test_install.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from mock import patch, Mock, MagicMock from path import Path import pytest diff --git a/cluster/juju/charms/trusty/kubernetes/hooks/hooks.py b/cluster/juju/charms/trusty/kubernetes/hooks/hooks.py old mode 100755 new mode 100644 index aeff669e91b..1a5e6645c63 --- a/cluster/juju/charms/trusty/kubernetes/hooks/hooks.py +++ b/cluster/juju/charms/trusty/kubernetes/hooks/hooks.py @@ -1,4 +1,19 @@ -#!/usr/bin/python +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """ The main hook file that is called by Juju. """ diff --git a/cluster/juju/charms/trusty/kubernetes/hooks/kubernetes_installer.py b/cluster/juju/charms/trusty/kubernetes/hooks/kubernetes_installer.py index d85beb47443..b7db6458446 100644 --- a/cluster/juju/charms/trusty/kubernetes/hooks/kubernetes_installer.py +++ b/cluster/juju/charms/trusty/kubernetes/hooks/kubernetes_installer.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import subprocess from path import path diff --git a/cluster/juju/charms/trusty/kubernetes/hooks/lib/__init__.py b/cluster/juju/charms/trusty/kubernetes/hooks/lib/__init__.py index e69de29bb2d..8eefd60722b 100644 --- a/cluster/juju/charms/trusty/kubernetes/hooks/lib/__init__.py +++ b/cluster/juju/charms/trusty/kubernetes/hooks/lib/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/cluster/juju/charms/trusty/kubernetes/hooks/lib/registrator.py b/cluster/juju/charms/trusty/kubernetes/hooks/lib/registrator.py index d8a57f0a7aa..42e06f2a18e 100644 --- a/cluster/juju/charms/trusty/kubernetes/hooks/lib/registrator.py +++ b/cluster/juju/charms/trusty/kubernetes/hooks/lib/registrator.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import httplib import json import time diff --git a/cluster/juju/charms/trusty/kubernetes/unit_tests/lib/test_registrator.py b/cluster/juju/charms/trusty/kubernetes/unit_tests/lib/test_registrator.py index 95f7c1dacaa..6c1238352c0 100644 --- a/cluster/juju/charms/trusty/kubernetes/unit_tests/lib/test_registrator.py +++ b/cluster/juju/charms/trusty/kubernetes/unit_tests/lib/test_registrator.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import json from mock import MagicMock, patch, call from path import Path diff --git a/cluster/juju/charms/trusty/kubernetes/unit_tests/test_hooks.py b/cluster/juju/charms/trusty/kubernetes/unit_tests/test_hooks.py index 49e59f44fc2..d1d17b4f176 100644 --- a/cluster/juju/charms/trusty/kubernetes/unit_tests/test_hooks.py +++ b/cluster/juju/charms/trusty/kubernetes/unit_tests/test_hooks.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # import pytest diff --git a/cluster/juju/return-node-ips.py b/cluster/juju/return-node-ips.py old mode 100755 new mode 100644 index a8848f019a6..5a6a7955a44 --- a/cluster/juju/return-node-ips.py +++ b/cluster/juju/return-node-ips.py @@ -1,4 +1,19 @@ #!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import json import sys # This script helps parse out the private IP addreses from the diff --git a/cluster/saltbase/salt/_states/container_bridge.py b/cluster/saltbase/salt/_states/container_bridge.py index ed64d71dd10..a856bcb7d9d 100644 --- a/cluster/saltbase/salt/_states/container_bridge.py +++ b/cluster/saltbase/salt/_states/container_bridge.py @@ -1,4 +1,6 @@ -# Copyright 2014 Google Inc. All rights reserved. +#!/usr/bin/env python + +# Copyright 2014 The Kubernetes Authors All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/examples/celery-rabbitmq/celery-app-add/celery_conf.py b/examples/celery-rabbitmq/celery-app-add/celery_conf.py index 903238f010a..237028cae3b 100644 --- a/examples/celery-rabbitmq/celery-app-add/celery_conf.py +++ b/examples/celery-rabbitmq/celery-app-add/celery_conf.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os from celery import Celery diff --git a/examples/celery-rabbitmq/celery-app-add/run_tasks.py b/examples/celery-rabbitmq/celery-app-add/run_tasks.py index 5f1434eff02..e07afc5010e 100644 --- a/examples/celery-rabbitmq/celery-app-add/run_tasks.py +++ b/examples/celery-rabbitmq/celery-app-add/run_tasks.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import random import syslog import time From c9cd50dc49da7a6172542bbbf8feea81de5a0eae Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Fri, 1 May 2015 17:25:49 -0400 Subject: [PATCH 2/2] Check python files for valid license boilerplate --- hack/verify-boilerplate.sh | 3 +++ hooks/boilerplate.py.txt | 16 ++++++++++++++++ hooks/prepare-commit-msg | 6 ++++++ 3 files changed, 25 insertions(+) create mode 100755 hooks/boilerplate.py.txt diff --git a/hack/verify-boilerplate.sh b/hack/verify-boilerplate.sh index 007f23a87f5..fdc14577178 100755 --- a/hack/verify-boilerplate.sh +++ b/hack/verify-boilerplate.sh @@ -46,6 +46,9 @@ files_need_boilerplate+=($(${boiler} "go" "${files[@]}")) files=($(find_files "sh")) files_need_boilerplate+=($(${boiler} "sh" "${files[@]}")) +files=($(find_files "py")) +files_need_boilerplate+=($(${boiler} "py" "${files[@]}")) + if [[ ${#files_need_boilerplate[@]} -gt 0 ]]; then for file in "${files_need_boilerplate[@]}"; do echo "Boilerplate header is wrong for: ${file}" diff --git a/hooks/boilerplate.py.txt b/hooks/boilerplate.py.txt new file mode 100755 index 00000000000..abc2e0e2b35 --- /dev/null +++ b/hooks/boilerplate.py.txt @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +# Copyright 2014 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/hooks/prepare-commit-msg b/hooks/prepare-commit-msg index 80a29ab934f..bfb6a07b77b 100755 --- a/hooks/prepare-commit-msg +++ b/hooks/prepare-commit-msg @@ -27,6 +27,12 @@ if [[ ${#files[@]} -gt 0 ]]; then files_need_boilerplate+=($("${boiler}" "sh" "${files[@]}")) fi +# Check for py files without the required boilerplate. +files=($(git diff --cached --name-only --diff-filter ACM | grep "\.py" | grep -v -e "third_party" -e "Godeps")) +if [[ ${#files} -gt 0 ]]; then + files_need_boilerplate+=($("${boiler}" "py" "${files[@]}")) +fi + # Check API schema definitions for field descriptions for file in $(git diff --cached --name-only --diff-filter ACM | egrep "pkg/api/v.[^/]*/types\.go" | grep -v "third_party"); do # Check for files with fields without description tags