Code Monkey home page Code Monkey logo

nc_py_api's Introduction

Nextcloud Python Framework

(Py)Analysis & Coverage PythonVersion impl pypi codecov

Framework(App) for Nextcloud to develop apps, that using Python.

Consists of PHP part(cloud_py_api app) and a Python module(nc-py-api).

Current state: Abandoned

Project was divided into two different repositories:

Provides Convenient Functions for Python

  • Read & Write File System objects
  • Working with Database
  • Wrapper around OCC calls
  • Calling your python function from php part of app and return a result

๐Ÿš€ Installation

In your Nextcloud, simply enable the cloud_py_api app through the Apps management and then install apps, that using it.

The Nextcloud cloud_py_api app supports Nextcloud version 25 and higher.

More information can be found on Wiki page

Maintainers

Apps using this

  • MediaDC - Nextcloud Media Duplicate collector app. Python part - core logics for duplicates search.

nc_py_api's People

Contributors

bigcat88 avatar jospoortvliet avatar pre-commit-ci[bot] avatar renovate[bot] avatar tschechniker 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nc_py_api's Issues

Uploading files could raise an error

Describe the bug

I'm trying to upload files using the with open method and upload_stream.
When I'm using filepath as str, everything is working as expected, and the file is uploaded.
When using the "with open" as per the docs, I'm getting encoding errors.
ERROR - 'charmap' codec can't decode byte 0x9d in position 30: character maps to

file_path I used:
"C:\nextconnect\00592295\parsed\12_26_2023_12_06PM_Logs (2)_parsed.7z"

Steps/Code to Reproduce

Not working: (both 'rb' and w/o 'rb', plus, I also tried using encoding='utf-8')

with open(seven_z_upload_file, 'rb') as f:
    file_path = file_path_in_str
    nextcloud_file_object = nc.files.upload_stream(file_path, seven_z_upload_file)

logger.info(f"Uploaded {nextcloud_file_object.full_path}")

Working:

file_path = file_path_in_str
nextcloud_file_object = nc.files.upload_stream(file_path, seven_z_upload_file)

logger.info(f"Uploaded {nextcloud_file_object.full_path}")

Expected Results

Upload files when using the with open, as well as w/o it.
@bigcat88 , as per your example in https://stackoverflow.com/a/77242950/6575170 , it is possible.

Actual Results

Getting error codes like 'charmap' codec can't decode byte 0x9d

Setup configuration

nc_py = 0.71

All special chars (like #) should be UrlEncoded

Describe the bug

As per the example:
https://github.com/cloud-py-api/nc_py_api/blob/main/examples/as_client/files/upload.py
I'm trying to upload file to a specific location:
I tried the following methods:

# seven_z_upload_file = 'C:\\nextconnect\\00592295\\parsed\\12_26_2023_12_06PM_Logs (2)_parsed.7z'
# main_nc_folder = '/SFDC_CASES/SFDC#'
# ticket_id = '1234'
# os.path.split(seven_z_upload_file)[1] = '12_26_2023_12_06PM_Logs (2)_parsed.7z'
with open(seven_z_upload_file) as f:
    file_path = main_nc_folder + ticket_id + '/' + os.path.split(seven_z_upload_file)[1]               
    nextcloud_file_object = nc.files.upload_stream(file_path, f)`

I also tried removing the first '/' with main_nc_folder.removeprefix('/') - nothing
I tried using the FSNode:

nc.files.upload_stream(nc.files.mkdir(main_nc_folder + '#####' + ticket_id).full_path + os.path.split(seven_z_upload_file)[1], seven_z_upload_file)

# nc.files.mkdir(main_nc_folder + '######' + ticket_id).full_path + os.path.split(seven_z_upload_file)[1] == 
'files/tomerb/SFDC_CASES/SFDC######00592295/12_26_2023_12_06PM_Logs (2)_parsed.7z'


path_temp = nc.files.mkdir(main_nc_folder + '###' + ticket_id).full_path`

file_path = main_nc_folder + ticket_id + '/' + os.path.split(seven_z_upload_file)[1]               
    nextcloud_file_object = nc.files.upload_stream(file_path, f)`

If it is working, I'm getting filename on my /SFDC_CASES named: SFDC

I'm getting 404, 409

@bigcat88 , Please LMK what should I do.
I can also contribute to writing more docs if needed.

Steps/Code to Reproduce

# seven_z_upload_file = 'C:\\nextconnect\\00592295\\parsed\\12_26_2023_12_06PM_Logs (2)_parsed.7z'
# main_nc_folder = '/SFDC_CASES/SFDC#'
# ticket_id = '1234'
# os.path.split(seven_z_upload_file)[1] = '12_26_2023_12_06PM_Logs (2)_parsed.7z'
with open(seven_z_upload_file) as f:
    file_path = main_nc_folder + ticket_id + '/' + os.path.split(seven_z_upload_file)[1]               
    nextcloud_file_object = nc.files.upload_stream(file_path, f)`
nc.files.upload_stream(nc.files.mkdir(main_nc_folder + '#####' + ticket_id).full_path + os.path.split(seven_z_upload_file)[1], seven_z_upload_file)

# nc.files.mkdir(main_nc_folder + '######' + ticket_id).full_path + os.path.split(seven_z_upload_file)[1] == 
'files/tomerb/SFDC_CASES/SFDC######00592295/12_26_2023_12_06PM_Logs (2)_parsed.7z'


path_temp = nc.files.mkdir(main_nc_folder + '###' + ticket_id).full_path`

file_path = main_nc_folder + ticket_id + '/' + os.path.split(seven_z_upload_file)[1]               
    nextcloud_file_object = nc.files.upload_stream(file_path, f)`

Expected Results

File named: '12_26_2023_12_06PM_Logs (2)_parsed.7z', located at folder: /SFDC_CASES/SFDC######00592295/

Actual Results

(When it's working) I'm getting a file named SFDC (no extension at all)

Setup configuration

nc_py = 0.71

Missing files.find() method usage, docs, examples, bug when searching by "name"

Discussed in #86

Originally posted by CooperGerman August 17, 2023
Hi,
I'm currently trying to implement some of the features of this package and i am facing some issues regarding the files.find() method.
I can't seem to properly use it and while debugging i found some code which i'm not very sure about in file nc_py_api/files/files.py lines 46-53.

SEARCH_PROPERTIES_MAP = {
    "name:": "d:displayname",  # like, eq
    "mime": "d:getcontenttype",  # like, eq
    "last_modified": "d:getlastmodified",  # gt, eq, lt
    "size": "oc:size",  # gt, gte, eq, lt
    "favorite": "oc:favorite",  # eq
    "fileid": "oc:fileid",  # eq
}

For entry "name" should there be the colon inside the string ?

Thanks in advance for any help, i would really appreciate an example of this method allowing to verify if a file exists in a folder.

Does we need the `GGUF` files download by link support in a `set_handlers`?

e.g.

MODEL_NAME = "https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.2-GGUF/blob/main/mistral-7b-instruct-v0.2.Q5_K_M.gguf"


@asynccontextmanager
async def lifespan(_app: FastAPI):
    ex_app.set_handlers(APP, enabled_handler, models_to_fetch={MODEL_NAME: {}})
    yield
    

with automatic progress display in AppAPI UI and with ETag support probably to autoupdate model if file was changes on server?

we can check start of string for "https/http" to detect if this is direct link to file

Or something else(additional files?) will be needed for GGUF models and we need a more complex struct?

cc @kyteinsky ?

edited: ETags support added only for huggingface(they use sha256 of file and X-Linked-ETag field), it should be enough.

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.