...
 
Commits (5)
......@@ -16,4 +16,7 @@
*.pyc
__pycache__/
# Auto generated by setup.py
/px/version.py
px.pex
......@@ -5,7 +5,12 @@
Installation
------------
To install into ``/usr/local/bin``, copy / paste this command into a terminal::
On `Debian 10 Buster`_ or later, and on `Ubuntu 19.04 Disco`_ and later, install using::
sudo apt-get install px
On other systems (macOs, other Linux distros, ...), install into ``/usr/local/bin`` by
copy / pasting this command into a terminal::
curl -Ls https://github.com/walles/px/raw/python/install.sh | bash
......@@ -171,6 +176,9 @@ information; the command will work without it but might miss some information.
Development
===========
Note that before editing any code, you need to run ``ci.sh`` first to create
the ``px/version.py`` file.
Note that the build infrastructure here is designed to create a ``px.pex`` file
that works on both Python 2 and Python 3, and on "all" machines with Python
interpreters (tested on Linux and OS X).
......@@ -282,6 +290,8 @@ DONE
* Run CI on both Python 2 and Python 3
.. _the Output section: #output
.. _Debian 10 Buster: https://wiki.debian.org/DebianBuster
.. _Ubuntu 19.04 Disco: https://launchpad.net/ubuntu/disco/
.. _download the latest px.pex: https://github.com/walles/px/releases/latest
.. _Unix domain sockets: https://en.wikipedia.org/wiki/Unix_domain_socket
.. _This support is available for many VMs: https://github.com/walles/px/blob/python/tests/px_commandline_test.py
......
......@@ -69,6 +69,10 @@ else
. "${ENVDIR}"/bin/activate
fi
# Call setup.py here to ensure version.py has been generated before we do anything
# else.
./setup.py check
if python --version 2>&1 | grep " 3" ; then
# Verson of "python" binary is 3, do static type analysis. Mypy requires
# Python 3, that's why we do this only on Python 3.
......@@ -115,7 +119,7 @@ echo
"${PX_PEX}" $$
echo
"${PX_PEX}" --version
test "$("${PX_PEX}" --version)" = "$(git describe --dirty)"
if pip list | grep '^pxpx ' > /dev/null ; then
# Uninstall px before doing install testing
......@@ -123,4 +127,4 @@ if pip list | grep '^pxpx ' > /dev/null ; then
fi
pip install "${ENVDIR}"/pxpx-*.whl
px bash
px --version
test "$(px --version)" = "$(git describe --dirty)"
px (1.0.15-1) unstable; urgency=medium
* New upstream release. (1.0.15-1):
- Refresh patch to avoid package version with git and add handling
of package version to the patch.
* Bump Standards-Version to 4.3.0, no changes were required.
-- Josue Ortega <josue@debian.org> Fri, 28 Dec 2018 15:53:11 -0600
px (1.0.13-2) unstable; urgency=medium
* debian/control: Change lsof declared relationship to Recommended
......
......@@ -9,7 +9,7 @@ Build-Depends: debhelper (>=11),
python3-pytest-cov,
python3-pytest-runner,
python3-dateutil
Standards-Version: 4.2.1
Standards-Version: 4.3.0
Homepage: https://github.com/walles/px/
X-Python3-Version: >= 3.6
Vcs-Browser: https://salsa.debian.org/debian/px
......
Description: Disables git command to get current version of the package.
Description: Disables git command to get current version of the package and use of
Version structure at command. Currently version is being hardcoded in order to
make px --version command work.
Author: Josue Ortega <josue@debian.org>
Last-Update: 2018-09-29
Last-Update: 2018-12-28
--- a/setup.py
+++ b/setup.py
@@ -14,7 +14,6 @@
setup(
name='pxpx',
- version=subprocess.check_output(['git', 'describe', '--dirty']).decode('utf-8').strip(),
description='ps and top for Human Beings',
long_description=LONG_DESCRIPTION,
author='Johan Walles',
@@ -6,11 +6,7 @@
from setuptools import setup
-git_version = subprocess.check_output(['git', 'describe', '--dirty']).decode('utf-8').strip()
-with tempfile.NamedTemporaryFile(suffix='.py', delete=False) as tmp:
- tmp.write(b"# NOTE: Auto generated by setup.py, no touchie!\n")
- tmp.write(b"VERSION = '%s'\n" % bytearray(git_version, "utf_8"))
- os.rename(tmp.name, "px/version.py")
+git_version = '0.0.0'
requirements = None
with open('requirements.txt') as reqsfile:
--- a/px/px.py
+++ b/px/px.py
@@ -45,7 +45,6 @@
from . import px_processinfo
# If this fails, run "ci.sh" once and the "version.py" file will be created for you.
-from . import version
def install():
@@ -67,7 +66,7 @@
if len(sys.argv) == 1 and os.path.basename(sys.argv[0]).endswith("top"):
sys.argv.append("--top")
- args = docopt.docopt(__doc__, version=version.VERSION)
+ args = docopt.docopt(__doc__, version='1.0.15')
if args['--install']:
install()
# You must remove unused comment lines for the released package.
000-fix-ptop-man.patch
000-avoid-version-gen.patch
000-fix-ptop-man.patch
......@@ -35,7 +35,6 @@ of which processes are most active right now.
"""
import sys
import pkg_resources
import os
import docopt
......@@ -45,6 +44,9 @@ from . import px_process
from . import px_terminal
from . import px_processinfo
# If this fails, run "ci.sh" once and the "version.py" file will be created for you.
from . import version
def install():
# Find full path to self
......@@ -61,15 +63,11 @@ def install():
px_install.install(px_pex, "/usr/local/bin/ptop")
def get_version():
return pkg_resources.get_distribution("pxpx").version
def main():
if len(sys.argv) == 1 and os.path.basename(sys.argv[0]).endswith("top"):
sys.argv.append("--top")
args = docopt.docopt(__doc__, version=get_version())
args = docopt.docopt(__doc__, version=version.VERSION)
if args['--install']:
install()
......
......@@ -11,24 +11,26 @@ import dateutil.tz
LAST_USERNAME = "([^ ]+)"
LAST_DEVICE = "([^ ]+)"
LAST_ADDRESS = "([^ ]+)?"
LAST_PID = "( \[[0-9]+\])?"
LAST_FROM = "(... ... .. ..:..)"
LAST_DASH = " [- ] "
LAST_TO = "[^(]*"
LAST_DURATION = "([0-9+:]+)"
LAST_RE = re.compile(
LAST_USERNAME +
" +" +
LAST_DEVICE +
" +" +
LAST_ADDRESS +
" +" +
LAST_FROM +
LAST_DASH +
LAST_TO +
" *(\(" +
LAST_DURATION +
"\))?"
LAST_USERNAME +
" +" +
LAST_DEVICE +
" +" +
LAST_ADDRESS +
LAST_PID +
" +" +
LAST_FROM +
LAST_DASH +
LAST_TO +
" *(\(" +
LAST_DURATION +
"\))?"
)
TIMEDELTA_RE = re.compile("(([0-9]+)\+)?([0-9][0-9]):([0-9][0-9])")
......@@ -89,8 +91,8 @@ def get_users_at(timestamp, last_output=None, now=None):
username = match.group(1)
address = match.group(3)
from_s = match.group(4)
duration_s = match.group(6)
from_s = match.group(5)
duration_s = match.group(7)
if address:
username += " from " + address
......
#!/usr/bin/env python
import os
import tempfile
import subprocess
from setuptools import setup
git_version = subprocess.check_output(['git', 'describe', '--dirty']).decode('utf-8').strip()
with tempfile.NamedTemporaryFile(suffix='.py', delete=False) as tmp:
tmp.write(b"# NOTE: Auto generated by setup.py, no touchie!\n")
tmp.write(b"VERSION = '%s'\n" % bytearray(git_version, "utf_8"))
os.rename(tmp.name, "px/version.py")
requirements = None
with open('requirements.txt') as reqsfile:
requirements = reqsfile.readlines()
......@@ -14,7 +21,7 @@ with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as fp:
setup(
name='pxpx',
version=subprocess.check_output(['git', 'describe', '--dirty']).decode('utf-8').strip(),
version=git_version,
description='ps and top for Human Beings',
long_description=LONG_DESCRIPTION,
author='Johan Walles',
......
......@@ -289,3 +289,14 @@ def test_to_timedelta(check_output):
assert px_loginhistory._to_timedelta("01:29") == datetime.timedelta(0, hours=1, minutes=29)
assert px_loginhistory._to_timedelta("4+01:29") == datetime.timedelta(4, hours=1, minutes=29)
assert px_loginhistory._to_timedelta("34+01:29") == datetime.timedelta(34, hours=1, minutes=29)
def test_realworld_debian(check_output):
"""
Regression test for https://github.com/walles/px/issues/48
"""
now = datetime.datetime(2016, 12, 6, 9, 21, tzinfo=dateutil.tz.tzlocal())
testtime = datetime.datetime(2016, 10, 24, 15, 34, tzinfo=dateutil.tz.tzlocal())
lastline = "norbert pts/3 mosh [29846] Wed Oct 24 15:33 - 15:34 (00:01)"
assert set(["norbert from mosh"]) == get_users_at(lastline, now, testtime)