RClone Wrapper for AWS Glue Python Shell
Project description
awsglue-rclone
awsglue-rclone is a wrapper for RClone designed for use with AWS Glue Python Shell, rclone everything within Glue!
Installation
Install awsglue-rclone from source:
$ git clone https://github.com/zhiweio/awsglue-rclone.git && cd awsglue-rclone/
$ python3 setup.py install
Usage
Install rclone on local machine (Glue shell)
from awsglue_rclone import RClone
rclone = RClone()
Build AWS S3 remote config
from awsglue_rclone.config import S3Config
cn_s3_conf = S3Config(
alias="cn",
properties={
"region": "cn-north-1",
"access_key_id": "xxx",
"secret_access_key": "xxx",
},
)
Create rclone.config file
rclone.create_remote(cn_s3_conf)
Build from Secrets Manager
secrets: rclone/aws_s3/us_west
{
"region": "us-west-1",
"access_key_id": "xxx",
"secret_access_key": "xxx",
}
us_s3_conf = S3Config(
alias="us",
secret="rclone/aws_s3/us_west",
)
rclone.create_remote(us_s3_conf, append=True)
List remote files
ret = rclone.ls("cn:bucket/yourfolder")
{
"code": 0,
"out": " 2079 README.md\n",
"error": ""
}
Print verbose
ret = rclone.ls("cn:bucket/yourfolder", debug=True)
{
"code": 0,
"out": " 2079 README.md\n",
"error": "2024/02/08 17:00:09 DEBUG : rclone: Version \"v1.64.2\" starting with parameters [\"rclone\" \"--config=/tmp/opt/.config/rclone.conf\" \"-vv\" \"ls\" \"cn:bucket/yourfolder/\"]\n2024/02/08 17:00:09 DEBUG : Creating backend with remote \"cn:bucket/yourfolder/\"\n2024/02/08 17:00:09 DEBUG : Using config file from \"/tmp/opt/.config/rclone.conf\"\n2024/02/08 17:00:09 DEBUG : fs cache: renaming cache item \"cn:bucket/yourfolder/\" to be canonical \"cn:bucket/yourfolder\"\n2024/02/08 17:00:09 DEBUG : 7 go routines active\n"
}
Copy files between two remotes, set nio=True to save command output (stdout/stderr) into temporary files
rclone.copy("cn:bucket/yourfolder", "us:bucket/yourfolder", nio=True)
{
"code": 0,
"out": "/var/folders/bj/h5g9fnl93dg6tllvsp4hr73r0000gn/T/tmpuhom0swf.stdout",
"error": "/var/folders/bj/h5g9fnl93dg6tllvsp4hr73r0000gn/T/tmp4jf_9nok.stderr"
}
Build other remote Config providers
from awsglue_rclone.config import Config, RemoteTypes
# provider for onedrive storage
class OneDriveConfig(Config):
def create(self):
token = {
"access_token": self.properties["access_token"],
"token_type": self.properties.get("token_type", "Bear"),
"refresh_token": self.properties["refresh_token"],
"expiry": "2018-08-26T22:39:52.486512262+08:00",
}
token = json.dumps(token)
drive_id = self.properties["drive_id"]
drive_type = "business"
return textwrap.dedent(
f"""
[{self.alias}]
type = {RemoteTypes.onedrive}
token = {token}
drive_id = {drive_id}
drive_type = {drive_type}
"""
)
Authors
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file awsglue_rclone-0.0.2-py3-none-any.whl.
File metadata
- Download URL: awsglue_rclone-0.0.2-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa787a3d4e1d48de1dc049248968c6589ef810c634ee7cd40ca047a46d102edc
|
|
| MD5 |
1b67f2914f5950a122c1c3670ea489f0
|
|
| BLAKE2b-256 |
67c150750befa237737d18be2f001beb0953990c890dd155c249b1f589485198
|