Code Monkey home page Code Monkey logo

lib-python's Introduction

Autocode standard library Python bindings

Basic Python bindings for Autocode standard library service accession. Python 2.x and 3.x supported.

Used to interface with services built using Autocode and the Autocode CLI.

The lib package is available on PyPI: lib and operates as zero-dependency interface to run StdLib functions. This means that you can utilize any service on StdLib without installing any additional dependencies, and when you've deployed services to StdLib, you have a pre-built Python SDK. For example.

from lib import lib

try:
    result = lib.yourUsername.hostStatus(name='Dolores Abernathy')
except RuntimeError as err:
    # handle error

To discover StdLib services, visit https://stdlib.com/search. To build a service, get started with the StdLib CLI tools.

Installation

To install in an existing Python project;

$ pip install lib

Usage

from lib import lib

# [1]: Call "utils.reflect" function, the latest version, from StdLib
result = lib.utils.reflect(key='value')
result = lib.utils.reflect({'key': 'value'}) # also works
result = lib.utils.reflect('value') # also works, if first parameter is "key"

# [2]: Call "utils.reflect" function from StdLib, with "dev" environment
result = lib.utils.reflect['@dev'](key='value')

# [3]: Call "utils.reflect" function from StdLib, with "release" environment
#      This is equivalent to (1)
result = lib.utils.reflect['@release'](key='value')

# [4]: Call "utils.reflect" function from StdLib, with specific version
#      This is equivalent to (1)
result = lib.utils.reflect['@0.0.1'](key='value')

# [5]: Call functions within the service (not just the defaultFunction)
#      This is equivalent to (1) when "main" is the default function
result = lib.utils.reflect.main(key='value')

# Valid string composition from first object property only:
result = lib['utils.reflect'](key='value')
result = lib['utils.reflect[@dev]'](key='value')
result = lib['utils.reflect[@release]'](key='value')
result = lib['utils.reflect[@0.0.1]'](key='value')
result = lib['utils.reflect.main'](key='value')
result = lib['utils.reflect[@dev].main'](key='value')
result = lib['utils.reflect[@release].main'](key='value')
result = lib['utils.reflect[@0.0.1].main'](key='value')

Sending File Data

In order to send file parameters, in Python 2.7 or 3.6, simply use;

lib.username.service(parameter=open('/path/to/file.jpg'))

Where parameter is the parameter name expecting a file type (type "buffer" as listed on StdLib).

Additional Information

To learn more about Autocode and the standard library, visit autocode.com or read the Autocode CLI documentation on GitHub.

You can follow the development team on Twitter, @AutocodeHQ.

Autocode is © 2016 - 2021 Polybit Inc.

lib-python's People

Contributors

keithwhor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lib-python's Issues

SSL Errors

Hey, so I started trying to use the library and was encountering a few SSL errors.

lib=4.0.0
OpenSSL v1.1.1c
Tried with python 3.6.4, and python 3.7.4

The first error I was getting was:
self._sslobj.do_handshake()
ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:777)

Without updating my code or changing anything it is now displaying a different SSl error:
self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1076)

I've tried two ways, both return the same SSL Wrong Version Number.

First:
lib.cfg['token'] = 'MY_TOKEN'
HaloAPI = lib.halo.infinite['@0.2.0']
result = HaloAPI.stats.matches.list(gamertag='citizen kwho')
pprint(result)

Second:
url = 'https://halo.api.stdlib.com/[email protected]/stats/matches/retrieve/'
params = {
'id': '26829e9a-7fab-4c2b-ac28-a62360e55946',
'Content-Type': 'application/json'
}
headers = {
'Authorization': f'Bearer {dev_token}'
}
response = requests.get(url, params=params, headers=headers, verify=False)
pprint(response.json()

I then tried to see if the URL would resolve in my browser expecting a 401 error since I didn't pass my token and got an SSL error there as well. I can't tell exactly if this error is with the acode python bindings, or more specifically with the halo.api.stdlib API itself. Any additional input would be appreciated.

SSL_Error

Update:
After additional poking and prodding, I cleared my cache and was able to get a 200 response using the gateway method using requests. But the Acode lib-python library still gives me a SSL wrong version error.

It seems to have only worked one time though, and is back to providing the SSL wrong version error again.

AttributeError: 'list' object has no attribute 'push'

I am trying to import the lib package in my python application and it seems to run into a problem where the package has a bug (as shown below)

ERROR:tornado.application:Uncaught exception POST /image?
...
Traceback (most recent call last):
...
  File "/usr/local/lib/python2.7/dist-packages/lib/__init__.py", line 136, in __call__
    body = self.__py2body__(args, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/lib/__init__.py", line 204, in __py2body__
    a.push(value)
AttributeError: 'list' object has no attribute 'push'

All I am doing is from lib import lib.

Is this a known problem? I am running this in a docker container where I run:
pip install lib on it.

Extensive Documentation

Hey in the README , we saw only the lib greet function. Please explain it fully how it works, how to install, the available functions etc

`lib` as module name?

Hello! Really interested in what you guys are doing with stdlib.

Just for the record - I'm a little concerned about the module name lib. I think a lot of developers use that as an internal module name, so it might be a problem.

I'm guessing you guys have thought about this, so just wondering what your thoughts are on this and if it's up for debate?

Test suite

This library should have a basic test suite.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.