Skip to content

Commit 4d19b25

Browse files
authored
Merge pull request #10 from RogueM/commit
using sys.exit
2 parents dc7698a + 8d35f68 commit 4d19b25

6 files changed

Lines changed: 74 additions & 12 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ library/debian/
1818
packaging/*tar.xz
1919
pip-log.txt
2020
pip-delete-this-directory.txt
21+
.DS_Store
22+

library/CHANGELOG.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
0.1.2
2-
-----
2+
-----
33

44
* Initial commit to Raspbian apt repository
55

66
0.1.1
7-
-----
7+
-----
88

99
* Increased delay in polling loop to avoid CPU hogging
1010

1111
0.0.2
12-
-----
12+
-----
1313

1414
* Many little bugfixes, for an actually working library
1515

library/cap1xxx.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,24 @@
88

99
import atexit
1010
import signal
11-
import sys
1211
import threading
1312
import time
13+
from sys import exit, version_info
1414

1515
try:
1616
from smbus import SMBus
1717
except ImportError:
18-
if sys.version_info[0] < 3:
18+
if version_info[0] < 3:
1919
exit("This library requires python-smbus\nInstall with: sudo apt-get install python-smbus")
20-
elif sys.version_info[0] == 3:
20+
elif version_info[0] == 3:
2121
exit("This library requires python3-smbus\nInstall with: sudo apt-get install python3-smbus")
2222

2323
try:
2424
import RPi.GPIO as GPIO
2525
except ImportError:
2626
exit("This library requires the RPi.GPIO module\nInstall with: sudo pip install RPi.GPIO")
2727

28+
__version__ = '0.1.2'
2829

2930
# DEVICE MAP
3031
DEFAULT_ADDR = 0x28

packaging/makeall.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# script control variables
44

5-
reponame="cap1xxx" # leave this blank for auto-detection
6-
libname="cap1xxx" # leave this blank for auto-detection
5+
reponame="" # leave this blank for auto-detection
6+
libname="" # leave this blank for auto-detection
77

88
debianlog="debian/changelog"
99
debcontrol="debian/control"
@@ -51,12 +51,13 @@ if [ -z "$reponame" ]; then
5151
repodir="$rootdir"
5252
reponame="$(basename $repodir)"
5353
fi
54+
reponame=$(echo "$reponame" | tr "[A-Z]" "[a-z]")
5455
fi
5556

5657
if [ -z "$libname" ]; then
5758
cd "$libdir"
5859
libname=$(grep "name" setup.py | tr -d "[:space:]" | cut -c 7- | rev | cut -c 3- | rev)
59-
cd "$debdir"
60+
libname=$(echo "$libname" | tr "[A-Z]" "[a-z]") && cd "$debdir"
6061
fi
6162

6263
echo "reponame is $reponame and libname is $libname"

packaging/makedeb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
gettools="yes"
3+
gettools="no"
44
setup="yes"
55
cleanup="yes"
66
pkgfiles=( "build" "changes" "deb" "dsc" "tar.xz" )

packaging/makelog.sh

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,76 @@
11
#!/bin/bash
22

3+
# script control variables
4+
5+
libname="" # leave this blank for auto-detection
6+
vlibwarn="yes"
7+
8+
debdir="$(pwd)"
9+
rootdir="$(dirname $debdir)"
10+
libdir="$rootdir/library"
11+
312
mainlog="CHANGELOG"
413
debianlog="debian/changelog"
5-
pypilog="../library/CHANGELOG.txt"
14+
pypilog="$libdir/CHANGELOG.txt"
15+
16+
# function define
17+
18+
success() {
19+
echo "$(tput setaf 2)$1$(tput sgr0)"
20+
}
21+
22+
inform() {
23+
echo "$(tput setaf 6)$1$(tput sgr0)"
24+
}
25+
26+
warning() {
27+
echo "$(tput setaf 1)$1$(tput sgr0)"
28+
}
29+
30+
newline() {
31+
echo ""
32+
}
633

734
# generate debian changelog
835

936
cat $mainlog > $debianlog
37+
inform "seeded debian changelog"
1038

1139
# generate pypi changelog
1240

1341
sed -e "/--/d" -e "s/ \*/\*/" \
1442
-e "s/.*\([0-9].[0-9].[0-9]\).*/\1/" \
1543
-e '/[0-9].[0-9].[0-9]/ a\
16-
-----' $mainlog | cat -s > $pypilog
44+
-----' $mainlog | cat -s > $pypilog
45+
46+
version=$(head -n 1 $pypilog)
47+
inform "pypi changelog generated"
48+
49+
# touch up version in setup.py file
50+
51+
if [ -n $(grep version "$libdir/setup.py" &> /dev/null) ]; then
52+
inform "touched up version in setup.py"
53+
sed -i "s/[0-9].[0-9].[0-9]/$version/" "$libdir/setup.py"
54+
else
55+
warning "couldn't touch up version in setup, no match found"
56+
fi
57+
58+
# touch up version in lib
59+
60+
if [ -z "$libname" ]; then
61+
cd "$libdir"
62+
libname=$(grep "name" setup.py | tr -d "[:space:]" | cut -c 7- | rev | cut -c 3- | rev)
63+
libname=$(echo "$libname" | tr "[A-Z]" "[a-z]") && cd "$debdir"
64+
fi
65+
66+
if grep -e "__version__" "$libdir/$libname.py" &> /dev/null; then
67+
sed -i "s/__version__ = '[0-9].[0-9].[0-9]/__version__ = '$version/" "$libdir/$libname.py"
68+
inform "touched up version in $(basename $libdir/$libname.py)"
69+
elif grep -e "__version__" "$libdir/$libname/__init__.py" &> /dev/null; then
70+
sed -i "s/__version__ = '[0-9].[0-9].[0-9]/__version__ = '$version/" "$libdir/$libname/__init__.py"
71+
inform "touched up version in $(basename $libdir/$libname/__init__.py)"
72+
elif [ "$vlibwarn" == "yes" ]; then
73+
warning "couldn't touch up __version__ in lib, no match found"
74+
fi
1775

1876
exit 0

0 commit comments

Comments
 (0)