Browse Source

Moved stuff around; added VERSION to __init__.py

tags/0.3.1
Johann Schmitz 2 years ago
parent
commit
a5c835fb77
8 changed files with 31 additions and 11 deletions
  1. 18
    6
      Makefile
  2. 4
    3
      setup.py
  3. 1
    0
      smartcheck/__init__.py
  4. 7
    1
      smartcheck/__main__.py
  5. 0
    0
      smartcheck/check.py
  6. 0
    0
      smartcheck/convert.py
  7. 0
    0
      smartcheck/disks.yaml
  8. 1
    1
      tests/check.py

+ 18
- 6
Makefile View File

@@ -1,29 +1,41 @@
1 1
 TARGET?=tests
2 2
 
3
+VERSION := $(shell grep -Po '"(.*)"' smartcheck/__init__.py | sed -e 's/"//g')
4
+
3 5
 test_default_python:
4
-	PYTHONPATH=".:./src" python tests/ -v
6
+	python tests/ -v
5 7
 
6 8
 test_py2:
7 9
 	@echo Executing test with python2
8
-	PYTHONPATH=".:./src" python2 tests/ -v
10
+	python2 tests/ -v
9 11
 
10 12
 test_py3:
11 13
 	@echo Executing test with python3
12
-	PYTHONPATH=".:./src" python3 tests/ -v
14
+	python3 tests/ -v
13 15
 
14 16
 test: test_py2 test_py3
15 17
 
16 18
 compile:
17 19
 	@echo Compiling python code
18
-	python -m compileall src/
20
+	python -m compileall smartcheck/
19 21
 
20 22
 compile_optimized:
21 23
 	@echo Compiling python code optimized
22
-	python -O -m compileall src/
24
+	python -O -m compileall smartcheck/
23 25
 
24 26
 coverage:
25 27
 	coverage erase
26
-	PYTHONPATH=".:./src" coverage run --source='src' --branch tests/__main__.py
28
+	coverage run --source='.' --omit 'tests/*,setup.py' --branch tests/__main__.py
27 29
 	coverage report -m
28 30
 
31
+sonar:
32
+	/usr/local/bin/sonar-scanner/bin/sonar-scanner -Dsonar.projectVersion=$(VERSION)
33
+
34
+clean:
35
+	find -name "*.py?" -delete
36
+	rm -f coverage.xml testresults.xml
37
+	rm -fr htmlcov dist build smart_check.egg-info
38
+
29 39
 travis: compile compile_optimized test_default_python coverage
40
+
41
+jenkins: travis sonar

+ 4
- 3
setup.py View File

@@ -3,16 +3,17 @@
3 3
 
4 4
 from setuptools import setup, find_packages
5 5
 
6
+from smartcheck import VERSION
7
+
6 8
 setup(
7 9
     name='smart-check',
8
-    version='0.3',
10
+    version=VERSION,
9 11
     description='A smart S.M.A.R.T. check',
10 12
     author='Johann Schmitz',
11 13
     author_email='johann@j-schmitz.net',
12 14
     url='https://ercpe.de/projects/smart-check',
13 15
     download_url='https://code.not-your-server.de/smart-check.git/tags/',
14
-    packages=find_packages('src'),
15
-    package_dir={'': 'src'},
16
+    packages=find_packages('.'),
16 17
     include_package_data=True,
17 18
     package_data = {'': ['*.yaml']},
18 19
     zip_safe=False,

src/smartcheck/__init__.py → smartcheck/__init__.py View File

@@ -1,2 +1,3 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
+VERSION="0.3.1"

src/smartcheck/main.py → smartcheck/__main__.py View File

@@ -1,11 +1,12 @@
1 1
 #!/usr/bin/env python
2 2
 # -*- coding: utf-8 -*-
3 3
 from argparse import ArgumentParser
4
-import os
5 4
 import shlex
6 5
 import sys
7 6
 import logging
8 7
 import subprocess
8
+
9
+from smartcheck import VERSION
9 10
 from smartcheck.check import SMARTCheck, AttributeWarning, DEFAULT_DISKS_FILE
10 11
 
11 12
 
@@ -47,9 +48,14 @@ if __name__ == "__main__":
47 48
     parser.add_argument('--ignore-attributes', help='Ignore this S.M.A.R.T. attributes (id or name)', nargs='*')
48 49
     parser.add_argument('-v', '--verbose', help='Verbose messages', action='store_true', default=False)
49 50
     parser.add_argument('--debug', help="Print debug messages", action="store_true", default=False)
51
+    parser.add_argument('--version', action='store_true', dest='version', help='show version and exit')
50 52
 
51 53
     args = parser.parse_args()
52 54
 
55
+    if args.version:
56
+        print("smart-check %s" % VERSION)
57
+        sys.exit(0)
58
+
53 59
     if args.file and any([args.interface, args.drive]):
54 60
         parser.error('-f/--file cannot be used with a device and/or -i/--interface')
55 61
 

src/smartcheck/check.py → smartcheck/check.py View File


src/smartcheck/convert.py → smartcheck/convert.py View File


src/smartcheck/disks.yaml → smartcheck/disks.yaml View File


+ 1
- 1
tests/check.py View File

@@ -4,7 +4,7 @@ import os
4 4
 from smartcheck.check import SMARTCheck, AttributeWarning
5 5
 
6 6
 samples_path = os.path.join(os.path.dirname(__file__), 'samples')
7
-db_path = os.path.join(samples_path, '../../src/smartcheck/disks.yaml')
7
+db_path = os.path.join(samples_path, '../../smartcheck/disks.yaml')
8 8
 
9 9
 class CheckTest(unittest.TestCase):
10 10
 

Loading…
Cancel
Save