Browse Source

Detect addition of executable files

When running pep8 checks, fail if executable
files have accidentally been added.

Co-Authored-By: Eric Harney <eharney@redhat.com>

Closes-Bug: 1566328
Change-Id: I7280c0403cd473cd4b88cfc021d4f605a7bb35f2
Tom Barron 3 years ago
parent
commit
1c2ec9b8cf
8 changed files with 43 additions and 0 deletions
  1. 0
    0
      manila/cmd/all.py
  2. 0
    0
      manila/cmd/api.py
  3. 0
    0
      manila/cmd/data.py
  4. 0
    0
      manila/cmd/manage.py
  5. 0
    0
      manila/cmd/scheduler.py
  6. 0
    0
      manila/cmd/share.py
  7. 42
    0
      tools/check_exec.py
  8. 1
    0
      tox.ini

+ 0
- 0
manila/cmd/all.py View File


+ 0
- 0
manila/cmd/api.py View File


+ 0
- 0
manila/cmd/data.py View File


+ 0
- 0
manila/cmd/manage.py View File


+ 0
- 0
manila/cmd/scheduler.py View File


+ 0
- 0
manila/cmd/share.py View File


+ 42
- 0
tools/check_exec.py View File

@@ -0,0 +1,42 @@
1
+#!/usr/bin/python
2
+#
3
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+#    not use this file except in compliance with the License. You may obtain
5
+#    a copy of the License at
6
+#
7
+#         http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+#    Unless required by applicable law or agreed to in writing, software
10
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+#    License for the specific language governing permissions and limitations
13
+#    under the License.
14
+
15
+# Print a list and return with error if any executable files are found.
16
+# Compatible with both python 2 and 3.
17
+
18
+import os.path
19
+import stat
20
+import sys
21
+
22
+if len(sys.argv) < 2:
23
+    print("Usage: %s <directory>" % sys.argv[0])
24
+    sys.exit(1)
25
+
26
+directory = sys.argv[1]
27
+
28
+executable = []
29
+
30
+for root, mydir, myfile in os.walk(directory):
31
+    for f in myfile:
32
+        path = os.path.join(root, f)
33
+        mode = os.lstat(path).st_mode
34
+        if stat.S_IXUSR & mode:
35
+            executable.append(path)
36
+
37
+if executable:
38
+    print("Executable files found:")
39
+    for f in executable:
40
+        print(f)
41
+
42
+    sys.exit(1)

+ 1
- 0
tox.ini View File

@@ -42,6 +42,7 @@ commands =
42 42
          tools/cover.sh \
43 43
          tools/check_logging.sh \
44 44
          run_tests.sh
45
+  {toxinidir}/tools/check_exec.py {toxinidir}/manila
45 46
   {toxinidir}/tools/check_logging.sh {toxinidir}/manila
46 47
 
47 48
 [testenv:genconfig]

Loading…
Cancel
Save