Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backwards compatibility with python #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
urbackup_server_web_api_wrapper.egg-info/*
dist/urbackup-server-web-api-wrapper-*.zip
urbackup_api/__pycache__/*
urbackup_server_web_api_wrapper.egg-info/*
dist/urbackup-server-web-api-wrapper-*.zip
urbackup_api/__pycache__/*
test.py
*.pyc
__pycache__
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include README.md
include README.md
include LICENSE.txt
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
requests
urllib3
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[metadata]
[metadata]
description-file = README.md
158 changes: 79 additions & 79 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='urbackup-server-web-api-wrapper',
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.6',
description='Python wrapper to access and control an UrBackup server',
long_description=long_description,
# The project's main homepage.
url='https://github.com/uroni/urbackup-server-python-web-api-wrapper',
# Author details
author='Martin Raiber',
author_email='[email protected]',
# Choose your license
license='Apache License 2.0',
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 3 - Alpha',
# Indicate who your project is intended for
'Intended Audience :: Developers',
# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: Apache Software License',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
# What does your project relate to?
keywords='urbackup web api client',
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
# Alternatively, if you want to distribute just a my_module.py, uncomment
# this:
# py_modules=["my_module"],
# List run-time dependencies here. These will be installed by pip when
# your project is installed. For an analysis of "install_requires" vs pip's
# requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=[],
# List additional groups of dependencies here (e.g. development
# dependencies). You can install these using the following syntax,
# for example:
# $ pip install -e .[dev,test]
extras_require={
'dev': [],
'test': [],
}
)
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path

here = path.abspath(path.dirname(__file__))

# Get the long description from the README file
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()

setup(
name='urbackup-server-web-api-wrapper',

# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.7',

description='Python wrapper to access and control an UrBackup server',
long_description=long_description,

# The project's main homepage.
url='https://github.com/uroni/urbackup-server-python-web-api-wrapper',

# Author details
author='Martin Raiber',
author_email='[email protected]',

# Choose your license
license='Apache License 2.0',

# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 3 - Alpha',

# Indicate who your project is intended for
'Intended Audience :: Developers',

# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: Apache Software License',

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],

# What does your project relate to?
keywords='urbackup web api client',

# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
packages=find_packages(exclude=['contrib', 'docs', 'tests']),

# Alternatively, if you want to distribute just a my_module.py, uncomment
# this:
# py_modules=["my_module"],

# List run-time dependencies here. These will be installed by pip when
# your project is installed. For an analysis of "install_requires" vs pip's
# requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=[],

# List additional groups of dependencies here (e.g. development
# dependencies). You can install these using the following syntax,
# for example:
# $ pip install -e .[dev,test]
extras_require={
'dev': [],
'test': [],
}
)
22 changes: 11 additions & 11 deletions test/stop_all.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import urbackup_api
server = urbackup_api.urbackup_server("http://127.0.0.1:55414/x", "admin", "foo")
for action in server.get_actions():
a = action["action"]
if a ==server.action_full_file or a==server.action_resumed_full_file:
print("Running full file backup: "+action["name"])
print("Stopping...")
import urbackup_api


server = urbackup_api.urbackup_server("http://127.0.0.1:55414/x", "admin", "foo")

for action in server.get_actions():
a = action["action"]
if a ==server.action_full_file or a==server.action_resumed_full_file:
print("Running full file backup: "+action["name"])

print("Stopping...")
server.stop_action(action)
144 changes: 72 additions & 72 deletions test/urbackup_api_test.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
import urbackup_api
import datetime
import time
server = urbackup_api.urbackup_server("http://127.0.0.1:55414/x", "admin", "foo")
for extra_client in server.get_extra_clients():
server.remove_extra_client(extra_client["id"])
computernames = """2.2.2.2
3.3.3.3"""
for line in computernames:
server.add_extra_client(line)
clients = server.get_status()
usage = server.get_usage()
if len(clients) != len(usage):
print("Failed to retreive usage or status information. Length of both lists is different.")
# Uncomment to format time differently
# locale.setlocale(locale.LC_TIME, "german")
diff_time = 3*24*60*60 # 3 days
for client in clients:
if client["lastbackup"]=="-" or client["lastbackup"] < time.time() - diff_time:
if client["lastbackup"]=="-" or client["lastbackup"]==0:
lastbackup = "Never"
else:
lastbackup = datetime.datetime.fromtimestamp(client["lastbackup"]).strftime("%x %X")
print("Last file backup at {lastbackup} of client {clientname} is older than three days".format(
lastbackup=lastbackup, clientname=client["name"] ) )
#if server.start_incr_file_backup("Johnwin7test-PC2"):
# print("Started file backup successfully")
#else:
# print("Failed to start file backup")
if not server.get_livelog():
print("Failed to get livelog contents"
settings = server.get_client_settings("Johnwin7test-PC2")
for key in settings:
print("{key}={value}".format(key=key, value=settings[key]))
print("Authkey: "+server.get_client_authkey("Johnwin7test-PC2"))
if server.change_client_setting("Johnwin7test-PC2", "max_image_incr", "40"):
print("Changed setting successfully")
else:
print("Failed to change setting")
settings = server.get_global_settings()
for key in settings:
print("Global: {key}={value}".format(key=key, value=settings[key]))
if server.set_global_setting("max_image_incr", "40"):
print("Changed global setting successfully")
else:
print("Failed to change global setting")
import urbackup_api
import datetime
import time


server = urbackup_api.urbackup_server("http://127.0.0.1:55414/x", "admin", "foo")

for extra_client in server.get_extra_clients():
server.remove_extra_client(extra_client["id"])

computernames = """2.2.2.2
3.3.3.3"""

for line in computernames:
server.add_extra_client(line)


clients = server.get_status()
usage = server.get_usage()

if len(clients) != len(usage):
print("Failed to retreive usage or status information. Length of both lists is different.")

# Uncomment to format time differently
# locale.setlocale(locale.LC_TIME, "german")

diff_time = 3*24*60*60 # 3 days
for client in clients:

if client["lastbackup"]=="-" or client["lastbackup"] < time.time() - diff_time:

if client["lastbackup"]=="-" or client["lastbackup"]==0:
lastbackup = "Never"
else:
lastbackup = datetime.datetime.fromtimestamp(client["lastbackup"]).strftime("%x %X")

print("Last file backup at {lastbackup} of client {clientname} is older than three days".format(
lastbackup=lastbackup, clientname=client["name"] ) )


#if server.start_incr_file_backup("Johnwin7test-PC2"):
# print("Started file backup successfully")
#else:
# print("Failed to start file backup")


if not server.get_livelog():
print("Failed to get livelog contents"

settings = server.get_client_settings("Johnwin7test-PC2")

for key in settings:
print("{key}={value}".format(key=key, value=settings[key]))

print("Authkey: "+server.get_client_authkey("Johnwin7test-PC2"))

if server.change_client_setting("Johnwin7test-PC2", "max_image_incr", "40"):
print("Changed setting successfully")
else:
print("Failed to change setting")


settings = server.get_global_settings()

for key in settings:
print("Global: {key}={value}".format(key=key, value=settings[key]))


if server.set_global_setting("max_image_incr", "40"):
print("Changed global setting successfully")
else:
print("Failed to change global setting")
Loading