Skip to content

xdevdoc otdmDriverProto

Bartlomiej Ceglik edited this page Mar 3, 2023 · 14 revisions

otdmDriverProto.py indepth explenation / documentation - coder edition

otdmDriverProto

To index

Table of Contents

otdmDriverProto

otdmDriverProto Objects

class otdmDriverProto()

This is a programer documentation for otdmDriverProto. If you want to your owne Driver this is a place to be. It's python code explenation of what is in back of the idea and functions. This one is running in shell layer in python3. More about otdmTools info is comming....

Plan in this is

To make tasks simple. Making work will be only by saing what to do but how to make it is Handle by selected corect DriverProto. It know if this work is on http API or file system or mysql database using some selections. Not important :) If you have driverProto for it it is in otdm-

  • You can use your driverProto from yss / bash / otdm- instance
  • one line tasks any ware
  • will do for using in packitso .deb builder

By implementing your DriverProto you can extend options and join the family otdm-

Example

$ otdmTools.py -dfs '/tmp' -oFile '--'

argument dfs if is same as your keyWord your driver will be execute to do the task. -oFile store data to output file if -- to stdout.

$ otdmTools.py -dfs '/tmp/abc123' -act MKDIR -oFile '--'

-act is not GET|POST|DELETE it will try your argument in try So you can put your own function handler and argument vector is pass from otdmTool.py

$ tm=`tempfile`;otdmTools.py -forceHost 192.168.43.220 -dnrfByUid "*" \
-oFile ${tm} >> /dev/null
cat ${tm} | jq '.[].id'

force different host then in .otdm/config.json / use Node-RED driver proto / GETAll () to tm file then jq .id from result

$ tm=`tempfile`
outTemp='{"name":.name,"path":.fullPath}'
otdmTools.py -dfs "/tmp" -oFile ${tm} >> /dev/null
cat ${tm} | jq '.[] | select( .isFile == false ) | '${outTemp}

Returns only directory from /tmp in array of dicts {"name":.name,"path":.fullPath}

.....
    "path": "//tmp/jsdoc-api"
 }
 {
   "name": "pyjsdoc",
   "path": "//tmp/pyjsdoc"
 }
.....

ver: 0.2.2

It's for inhereting and overriting some of it's function / method.

There is a name restriction for new files otdmDriverYOURNAME.py Adding otdmDriverYOURNAMEProto.py in name will make skip your file in plugin init step.

All your driversProto should to extand by otdmDriverProto

nice cmd: python import pdb; pdb.set_trace()

keyWord

keyWord: string - @overwriteIt important to invoce from arguments from console.

iKey

iKey: string - @overwriteIt if want to use driver in packitso

iUid

iUid: string - @overwriteIt if want to use driver int packitso

isPackitso

isPackitso: bool - @overwriteIt important to use in packitso only if ready

__init__

def __init__(args, conf, name, suffix)

Arguments

  • args: dict - with argumens to parse and look for your inputs
  • conf: dict - from otdmTools.py instance .otdm/config.json is comming
  • name: string - to identyfy in .otdm/config.json
  • suffix: string | dict - to pass some args in instance

getHelp

def getHelp(implemented=0)

@overwriteIt - to set your own help as extra. After the default $ otdmTools.py -h '1'

getHost

def getHost()

@overwriteIt - use rest as curl instance for http api HOST:getPort/getSuffix/getApiPath Returns

[string] - host defined from config and iff set handles -forceHost (then call super)

getPort

def getPort()

@overwriteIt - use rest as curl instance for http api getHost:PORT/getSuffix/getApiPath Returns

[string] - port defined from config

getSuffix

def getSuffix()

@overwriteIt - use rest as curl instance for http api getHost:getPort/suffix/getApiPath Returns

[string] - suffix defined from self.suffix set on super()

getApiPath

def getApiPath()

@overwriteIt - use rest as curl instance for http api getHost:getPort/getSuffix/path Returns

[string] - suffix defined from config

getHeaders

def getHeaders()

@overwriteIt - if want to make http api with this header or overwriteit

GETAll

def GETAll()

@overwriteIt - to hendle request of all something like all Returns

[list] - of data some form

GET

def GET(d)

@overwriteIt - to hendle request of single work read Arguments

  • d: object - to identyfy your work to get it Returns

[list] - data some form file storable json preffered

POST

def POST(d)

@overwriteIt - to hendle request of single work write / make / execute / do taks Arguments

  • d: object - to put in work as data input to work Returns

[json] - to raport status

DELETE

def DELETE(d)

@overwriteIt - to hendle request of deleting / removing / dropping / eresing something like all Returns

[list] - to raport status

Clone this wiki locally