Skip to content

Commit 7465f65

Browse files
committed
create a package for simpler setup
1 parent 4b6f4c5 commit 7465f65

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

distance_locker.py renamed to distance_locker/__init__.py

-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55
import os
66
import sys
7-
import argparse
87
from pathlib import Path
98
from itertools import cycle
109
from collections import deque
@@ -34,16 +33,6 @@
3433
'The screensaver is inactive')
3534

3635

37-
def main():
38-
parser = argparse.ArgumentParser()
39-
parser.add_argument(
40-
'-a', '--address',
41-
required=True,
42-
help='Your phone or another bluetooth device MAC Address')
43-
options = parser.parse_args()
44-
return bluetooth_distance_locker(options.address)
45-
46-
4736
def bluetooth_distance_locker(device_mac_address):
4837
commend = [str(SENSOR_SCRIPT_PATH), device_mac_address]
4938
queue = deque(maxlen=5)
@@ -100,7 +89,3 @@ def check_screen_save_status():
10089
state = UNLOCK_STATE
10190
run(LOCKER_UNLOCK_COMMAND.split())
10291
print_state()
103-
104-
105-
if __name__ == '__main__':
106-
sys.exit(main())

distance_locker/__main__.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import sys
2+
import argparse
3+
from distance_locker import bluetooth_distance_locker
4+
5+
6+
def main():
7+
parser = argparse.ArgumentParser()
8+
parser.add_argument(
9+
'-a', '--address',
10+
required=True,
11+
help='Your phone or another bluetooth device MAC Address')
12+
options = parser.parse_args()
13+
return bluetooth_distance_locker(options.address)
14+
15+
if __name__ == '__main__':
16+
sys.exit(main())

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/usr/bin/env python
22
from distutils.core import setup
3+
from setuptools import find_packages
34

45
setup(
56
name='distance_locker',
67
version='0.0.1',
78
url='https://github.com/liormizr/linux_distance_locker',
89
author='Lior Mizrahi',
910
author_email='li.mizr@gmail.com',
10-
py_modules=['distance_locker'],
11-
scripts=['bluetooth_distance_sensor.sh'],
11+
packages=find_packages(),
1212
entry_points={
1313
'console_scripts': [
14-
'distance_locker = distance_locker:main',
14+
'distance_locker = distance_locker.__main__:main',
1515
]},
1616
)

0 commit comments

Comments
 (0)