Skip to content

Commit 93fae77

Browse files
authored
Merge pull request #4 from tuxberlin/update-build-process
Update build process
2 parents ca3498c + 8cbef06 commit 93fae77

15 files changed

+134
-238
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ _trash/
1414

1515
# Python
1616
__pycache__/
17+
.pytest_cache/
1718
*.py[cod]
1819
*$py.class
1920
*.so

.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

Makefile

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
init:
2-
pip install -r requirements.txt
2+
python3 -m pip install -r requirements.txt
3+
python3 -m pip install -r requirements-dev.txt
34

45
test:
5-
pytest tests
6+
python3 -m pytest tests
67

78
build:
8-
bash make-readme-toc.sh
9-
python setup.py sdist
10-
python setup.py bdist_wheel
9+
python3 -m build
1110

12-
pypi: clean build
13-
twine upload dist/* -r testpypi
11+
pypi:
12+
python3 -m twine upload --repository testpypi dist/*
13+
python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps keyctl
1414

15-
pypi-real: clean build
16-
@read -r -p "Are you sure? " INPUT; \
15+
pypi-real:
16+
@read -r -p "Are you sure to upload to real pypi? " INPUT; \
1717
if [ "$$INPUT" != "y" ] ; then exit 1 ; fi
18-
twine upload dist/*
18+
python3 -m twine upload dist/*
1919

2020
clean:
21+
pip freeze | xargs pip uninstall keyctl -y
2122
find . -type f -name '*~' -delete
2223
find . -type f -name '*.o' -delete
2324
find . -type f -name '*.pyc' -delete
24-
rm -rf build dist .cache *.egg-info tests/__pycache__
25-
25+
find . -type d -name '__pycache__' -delete
26+
rm -rf build dist .cache *.egg-info .pytest_cache tests/.pytest_cache

README.md

Lines changed: 59 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
11
[//]: # (-*- coding: utf-8 -*-)
22

3-
[![Travis](https://img.shields.io/travis/tuxberlin/python-keyctl/master.svg)](https://travis-ci.org/tuxberlin/python-keyctl)
43
[![PyPI Package version](https://img.shields.io/pypi/v/keyctl.svg)](https://pypi.python.org/pypi/keyctl)
54
[![PyPI Python version](https://img.shields.io/pypi/pyversions/keyctl.svg)](https://pypi.python.org/pypi/keyctl)
65
[![License](https://img.shields.io/github/license/tuxberlin/python-keyctl.svg)](https://raw.githubusercontent.com/tuxberlin/python-keyctl/master/LICENSE)
76

87

9-
# python-keyctl
8+
<h1>python-keyctl</h1>
109

1110
Basic management of keys in the Linux kernel keyring in Python. Also comes with a small gui.
1211

12+
* [Description](#description)
13+
* [Requirements](#requirements)
14+
* [Installation](#installation)
15+
* [Usage](#usage)
16+
* [Module](#module)
17+
* [GUI](#gui)
18+
* [Development](#development)
19+
* [Warning](#warning)
20+
* [Similar projects](#similar-projects)
21+
* [License](#license)
1322

14-
## Table of contents
1523

16-
[//]: # (AUTO TOC BEGIN)
1724

18-
* [Description](#description)
19-
* [Requirements](#requirements)
20-
* [Installation](#installation)
21-
* [Usage](#usage)
22-
* [Module](#module)
23-
* [GUI](#gui)
24-
* [Development](#development)
25-
* [Warning](#warning)
26-
* [Similar projects](#similar-projects)
27-
* [License](#license)
25+
# Description
2826

29-
[//]: # (AUTO TOC END)
30-
31-
32-
## Description
33-
34-
This is a small library to make use of some functions of the kernel keyring in Python. You can read, add and delete keys.
27+
This is a small library to make use of some functions of the kernel keyring in Python.
28+
You can read, add and delete keys.
3529

3630
It simply uses the keyctl command (invoking it via subprocess), so this util must be installed.
3731

@@ -46,68 +40,51 @@ Available functions:
4640
* **search/request** *(search for a key by name)*
4741
* **clear** *(remove all keys from keyring)*
4842

49-
There are many more functions with keys in the kernel keyring (e.g. permissions) that is needed for proper keymanagement. But for my usecase I just needed the given simple functionality.
43+
There are many more functions with keys in the kernel keyring (e.g. permissions)
44+
that is needed for proper keymanagement. But for my usecase I just needed the
45+
given simple functionality.
5046

47+
:warning: You might need to link your keyrings (e.g. for the testcases using the default keyring)
48+
to have proper permissions.
49+
E.g.:
50+
```sh
51+
$ keyctl link @u @s
52+
```
5153

52-
## Requirements
5354

54-
Python 2.7
55-
```
56-
$ sudo apt-get install python2.7
55+
# Requirements
56+
57+
Python 3.9
58+
```sh
59+
$ sudo apt install python3.9
5760
$ python --version
58-
Python 2.7.3
61+
Python 3.9.18
5962
```
6063

6164
pip
62-
```
63-
$ sudo apt-get install python-pip
65+
```sh
66+
$ sudo apt install python3-pip
6467
$ pip --version
65-
pip 9.0.1 from .... (python 2.7)
68+
pip 23.3.2 from .... (python 3.9)
6669
```
6770

6871
The 'keyctl' command
69-
```
70-
$ sudo apt-get install keyutils
72+
```sh
73+
$ sudo apt install keyutils
7174
$ dpkg -s keyutils | grep Version
72-
Version: 1.5.2-2
73-
```
74-
75-
For the GUI you also need:
76-
77-
Qt4
78-
```
79-
$ sudo apt-get install qt4-qmake libqt4-core libqt4-dev
80-
$ qmake-qt4 --version
81-
QMake version 2.01a
82-
Using Qt version 4.8.1 in /usr/lib/x86_64-linux-gnu
83-
```
84-
85-
PySide
86-
```
87-
$ sudo apt-get install python-qt4 python-pyside
88-
$ python -c "import PySide; print PySide.__version__"
89-
Version: 1.1.0
75+
Version: 1.6.1
9076
```
9177

92-
Virtualenv:
93-
If you want to use this module in a virtualenv you either have to
94-
`(venv)$ pip install pyside` (which takes up to 40min to compile)
95-
or you can link your pyside distro package into your virtualenv like this:
78+
If you want to use the GUI, you also need PySide6
9679
```
97-
$ cd myprojectfolder
98-
$ ln -s /usr/lib/python2.7/dist-packages/PySide/ venv/lib/python2.7/site-packages/
80+
$ pip install pyside6
81+
$ python3 -c "import PySide6; print(PySide6.__version__)"
82+
6.6.1
9983
```
10084

101-
try it:
102-
```
103-
$ cd myprojectfolder
104-
$ source venv/bin/activate
105-
(venv)$ python -c "import PySide; import os; print PySide.__version__, os.path.realpath(PySide.__path__[0])"
106-
1.1.0 /usr/lib/python2.7/dist-packages/PySide
107-
```
10885

10986

110-
## Installation
87+
# Installation
11188

11289
```
11390
$ pip install keyctl
@@ -116,38 +93,39 @@ $ pip install keyctl
11693
Ready to use.
11794

11895

119-
## Usage
12096

121-
### Module
97+
# Usage
98+
99+
## Module
122100
Get all keys:
123101
```python
124102
from keyctl import Key
125103
keylist = Key.list()
126104
for mykey in keylist:
127-
print mykey.id
105+
print(mykey.id)
128106
```
129107

130108
Read existing key:
131109
```python
132110
from keyctl import Key
133111
mykey = Key(123)
134-
print mykey.name
135-
print mykey.data
136-
print mykey.data_hex
112+
print(mykey.name)
113+
print(mykey.data)
114+
print(mykey.data_hex)
137115
```
138116

139117
Find key by name:
140118
```python
141119
from keyctl import Key
142120
mykey = Key.search('test key')
143-
print mykey.id
121+
print(mykey.id)
144122
```
145123

146124
Add key:
147125
```python
148126
from keyctl import Key
149127
mykey = Key.add('test key', 'test content')
150-
print mykey.id
128+
print(mykey.id)
151129
```
152130

153131
Delete key:
@@ -165,7 +143,7 @@ mykey.update('new content')
165143
```
166144

167145

168-
### GUI
146+
## GUI
169147
To open the GUI, run the installed command.
170148
```
171149
$ keyctlgui
@@ -175,22 +153,25 @@ $ keyctlgui
175153

176154

177155

178-
## Development
156+
# Development
179157

180-
### Warning
158+
## Warning
181159

182-
If you run the integrated tests, your user keyring will be cleared. Don't do this when you have active keys e.g. for encryption.
160+
If you run the integrated tests, your user keyring will be cleared.
161+
Don't do this when you have active keys e.g. for encryption.
183162

184163

185-
## Similar projects
186164

187-
Similar projects you might want to checkout:
165+
# Similar projects
166+
167+
Similar projects you might want to check out:
188168

189169
* https://github.com/sassoftware/python-keyutils (more complete, available in debian repo)
190170
* https://github.com/jdukes/pykeyctl (more complete, direct library wrapper)
191171

192172

193-
## License
173+
174+
# License
194175

195176
GPL-3.0
196177
see [LICENSE](https://raw.githubusercontent.com/tuxberlin/python-keyctl/master/LICENSE) file

keyctl/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616
try:
1717
subprocess.check_output(['which', 'keyctl'])
1818
except subprocess.CalledProcessError:
19-
raise OSError('The commandline util \'keyctl\' must be installed to use this module. ' +
20-
'Install it via \'apt-get install keyutils\'.')
19+
raise OSError(
20+
'The commandline util \'keyctl\' must be installed to use this module. ' +
21+
'Install it via \'apt-get install keyutils\'.'
22+
)

keyctl/gui/gui.py renamed to keyctl/gui/_gui.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
import os
5-
from PySide.QtUiTools import QUiLoader
6-
from PySide.QtGui import QMainWindow, QDesktopWidget, QTableWidgetItem, QDialog
5+
from PySide6.QtUiTools import QUiLoader
6+
from PySide6.QtWidgets import QMainWindow, QTableWidgetItem, QDialog
7+
from PySide6.QtGui import QGuiApplication
78

89
from keyctl import Key
910

@@ -42,7 +43,7 @@ def __init__(self):
4243
self._refresh_table()
4344

4445
def center_window(self):
45-
coords = QDesktopWidget().availableGeometry().center()
46+
coords = QGuiApplication.primaryScreen().availableGeometry().center()
4647
fg = self.ui.frameGeometry()
4748
fg.moveCenter(coords)
4849
self.ui.move(fg.topLeft())
@@ -67,7 +68,7 @@ def _open_add_dialog(self):
6768
name, content = dialog.get_input()
6869
Key.add(name, content)
6970
else:
70-
print 'ERROR'
71+
print('ERROR')
7172

7273
self._refresh_table()
7374

keyctl/gui/main.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22
# -*- coding: utf-8 -*-
33

44
import sys
5-
from PySide.QtGui import QApplication
5+
from PySide6.QtCore import Qt, QCoreApplication
6+
from PySide6.QtWidgets import QApplication
67

7-
from gui import KeyringApp
8+
from keyctl.gui._gui import KeyringApp
89

910

1011
# -------------------------------------------------------------------
1112

1213

1314
def main():
15+
QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
16+
1417
app = QApplication(sys.argv)
1518

1619
window = KeyringApp()
1720
window.ui.show()
1821
window.center_window()
1922
window.activateWindow()
2023

21-
ret = app.exec_()
24+
ret = app.exec()
2225
sys.exit(ret)
2326

2427

0 commit comments

Comments
 (0)