Commit e0ce37e2 authored by Klaus Reuter's avatar Klaus Reuter

renamed package to pocli because of PyPI conflict, improved README

parent 6d4e0cad
The MIT License (MIT)
Copyright (c) 2016, 2017 Florian Kaiser, fek@rzg.mpg.de
Klaus Reuter, khr@rzg.mpg.de
Copyright (c) 2016, 2017
Florian Kaiser, fek@rzg.mpg.de, Klaus Reuter, khr@rzg.mpg.de
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
......
Python OwnCloud Client (poc)
============================
Python OwnCloud Client (pocli)
==============================
Copyright (c) 2016, 2017 Florian Kaiser (fek@rzg.mpg.de), Klaus Reuter (khr@rzg.mpg.de)
Copyright (c) 2016, 2017
Florian Kaiser (fek@rzg.mpg.de), Klaus Reuter (khr@rzg.mpg.de)
Introduction
------------
The pocli package provides a lightweight OwnCloud command line client for basic
file operations such as upload, download, directory creation and listing, and
deletion. It is built upon the official pyocclient package.
Requirements and installation
-----------------------------
poc was developed and tested with Python 2.7.12 and Python 3.5.2.
pocli was developed and tested with Python 2.7.12 and Python 3.5.2.
As a requirement, poc needs the official OwnCloud Python module:
As a requirement, pocli needs the official OwnCloud Python module:
`pip install --user pyocclient`
The poc package itself can be installed in the standard way:
The pocli package itself can be installed in the standard way:
`python setup.py install --user`
Make sure to add the installation directory to the PATH environment variable,
on a Unix system this is for example "~/.local/bin". The previous examples
passed the "--user" flag in order to work purely in the user's homedirectory.
In case this flag is omitted, system-wide locations are chosen if the
permissions allow this.
pass the "--user" flag in order to work purely in the user's homedirectory. In
case this flag is omitted, system-wide locations are chosen.
Functionality examples (optional arguments are given in parentheses)
--------------------------------------------------------------------
The pocli package provides the single `poc` command. It takes positional and
named arguments in analogy to `git`. The following examples illustrate the
basic usage:
* basic help
`poc --help`
* command specific help
* command-specific help
`poc command --help`
......@@ -42,7 +54,7 @@ Functionality examples (optional arguments are given in parentheses)
* list remote files and folders, defaults to "/"
`poc ls (remote_folder)`
`poc ls <remote_folder>`
* create remote directory "temp"
......@@ -72,10 +84,10 @@ Functionality examples (optional arguments are given in parentheses)
Under the hood
--------------
The connection to an OwnCloud instance requires a valid
configuration. The configuration file is located at "~/.pocrc" and created at
the first invocation of the `poc` command. The default configuration is for
the MPCDF datashare service, however, it can be configured freely to connect to
The connection to an OwnCloud instance requires a valid configuration. The
configuration file in JSON format is located at "~/.pocrc" and created at the
first invocation of the `poc` command. The default configuration is for the
MPCDF datashare service, however, it can be configured freely to connect to
other OwnCloud instances. No credentials are ever stored in "~/.pocrc".
......@@ -83,14 +95,15 @@ Credentials and security considerations
---------------------------------------
Security concerns arise, in particular if the OwnCloud password is identical to
the password used for other services at a site.
the password used for other services at the same site.
The environment variable OC_PASSWORD may be set to a valid password, for security
reasons using the `pocpasswd` bash function from `pocpasswd.sh` in order to
prevent the plain text password from showing up in the shell history. Support
for other shells may follow later. When using OC_PASSWORD, close the shell as
soon as possible after the file transfer operations have been done.
Execute the commands `source pocpasswd.bash` followed by `pocpasswd`.
The environment variable OC\_PASSWORD may be set to a valid password, for
security reasons using the `pocpasswd` bash function from `pocpasswd.sh` in
order to prevent the plain text password from showing up in the shell history.
Execute the commands `source pocpasswd.bash` followed by `pocpasswd`. Support
for other shells may follow later. When using OC\_PASSWORD, unset it or close
the shell as soon as possible after the file transfer operations have been
done.
In case the environment variable OC_PASSWORD is not set the `poc` command asks
In case the environment variable OC\_PASSWORD is not set the `poc` command asks
for the password at every invocation.
"""poc command line entry point
"""pocli command line entry point
"""
......
"""poc library and basic methods
"""pocli library and basic methods
Initial version based on "pyocclient.py" by Florian Kaiser.
Initial version based on the program "pyocclient.py" by Florian Kaiser.
"""
import os
import sys
import math
#import yaml
import json
import time
import locale
......@@ -32,7 +31,6 @@ def init_pocrc():
config['OC_DEBUG'] = False
rcfile = get_pocrc()
with open(rcfile, 'w') as fp:
#yaml.dump(config, fp, default_flow_style=False)
fp.write( json.dumps(config, sort_keys=True, indent=4, separators=(',', ': ')) )
print("created config file: " + rcfile)
......@@ -46,7 +44,6 @@ def _client():
config = {}
rcfile = get_pocrc()
with open(rcfile, 'r') as fp:
#config = yaml.load(fp)
config = json.loads( fp.read() )
config['OC_PASSWORD'] = password
client = owncloud.Client(config['OC_SERVER'], debug=config['OC_DEBUG'])
......
# Helper function to allow to set the password for poc as environment variable
# without having it appear in bash history.
# Source ("source") this file into your bash session and then call `pocpasswd`.
# without having it appear in bash history. Source ("source pocpasswd.bash")
# this file into your bash session, and call `pocpasswd`.
function pocpasswd() {
echo -n "OwnCloud password (will not be echoed/visible): "
......
"""poc setup script
"""pocli (Python OwnCloud Client) setup script
"""
from setuptools import setup
import os
from setuptools import setup, Command
class CleanCommand(Command):
"""Custom clean command to tidy up the project root."""
# https://stackoverflow.com/questions/3779915/why-does-python-setup-py-sdist-create-unwanted-project-egg-info-in-project-r
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system('rm -vrf build')
os.system('rm -vrf dist')
os.system('rm -vrf pocli.egg-info')
os.system('rm -vrf pocli/__pycache__')
os.system("find . -name '*.pyc' -delete -print")
entry_points = {
'console_scripts': ['poc=poc.cli:main']
'console_scripts': ['poc=pocli.cli:main']
}
setup(name='poc',
setup(name='pocli',
version='0.1',
description='Python-based minimal command line interface for OwnCloud',
description='Python-based minimal command-line client for OwnCloud',
author='Florian Kaiser, Klaus Reuter',
author_email='khr@mpcdf.mpg.de',
packages=['poc'],
install_requires=['pyocclient'],
packages=['pocli'],
install_requires=['requests', 'pyocclient'],
cmdclass={'clean': CleanCommand},
entry_points=entry_points,
zip_safe=False)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment