Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have Organize start up and stay running for interaction at the command line, (rather than run a config.yml and close)? #374

Closed
nodecentral opened this issue Mar 24, 2024 · 5 comments

Comments

@nodecentral
Copy link

I’m so sorry, I’m not sure to report this as a bug, but also not sure how much of a new feature it is either.

To set the scene - I currently get the following error in the logs, after setting up a new Docker instance, all of which I think is understandable. My question however is how can I get Organize to start up, and stay running - allowing me to then interact with it via the command line so I can run many different config.yml files I have?

organize 2.4.0
Config: "/home/pi/.config/organize/config.yaml"
Working dir: ""
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /usr/local/lib/python3.8/site-packages/organize/cli.py:151 in execute        │
│                                                                              │
│   148 │                                                                      │
│   149 │   try:                                                               │
│   150 │   │   console.info(config=config_path, working_dir=working_dir)      │
│ ❱ 151 │   │   core.run(                                                      │
│   152 │   │   │   rules=config_text,                                         │
│   153 │   │   │   simulate=simulate,                                         │
│   154 │   │   │   working_dir=working_dir,                                   │
│                                                                              │
│ /usr/local/lib/python3.8/site-packages/organize/core.py:374 in run           │
│                                                                              │
│   371 │   rules = config.cleanup(rules)                                      │
│   372 │   Action.Meta.default_filesystem = working_dir                       │
│   373 │                                                                      │
│ ❱ 374 │   migrate_v1(rules)                                                  │
│   375 │                                                                      │
│   376 │   if validate:                                                       │
│   377 │   │   config.validate(rules)                                         │
│                                                                              │
│ /usr/local/lib/python3.8/site-packages/organize/migration.py:30 in           │
│ migrate_v1                                                                   │
│                                                                              │
│   27 │   │   if "folders" in rule:                                           │
│   28 │   │   │   raise NeedsMigrationError("`folders` are now `locations`")  │
│   29 │   │   for fil in rule.get("filters") or []:                           │
│ ❱ 30 │   │   │   name, _ = entry_name_args(fil)                              │
│   31 │   │   │   if name == "filename":                                      │
│   32 │   │   │   │   raise NeedsMigrationError("`filename` is now `name`")   │
│   33 │   │   │   if name == "filesize":                                      │
╰──────────────────────────────────────────────────────────────────────────────╯
TypeError: cannot unpack non-iterable NoneType object

Just to check the above error is related to where my config.yml is? Which is Config: "/home/pi/.config/organize/config.yaml" and that still contains the following default.

# organize configuration file
# https://organize.readthedocs.io

rules:
  - name: "The name of this rule"
    locations:
      - # your locations here
    filters:
      - # your filters here
    actions:
      - # your actions here

As I don’t want Organize to just run one Config file and close, is there a config.yml I can use, or something else I can do to just bring Organize up?

Or perhaps is there an edit I can make to the docker.entrypoint.sh ?

#!/bin/sh

if [ $# -eq 1 ]
  then
    (crontab -l 2>/dev/null; echo "$1 /usr/local/bin/organize run >> /var/log/organize/organize.log 2>&1") | crontab -
    service cron restart
    /bin/bash
  else
	  /usr/local/bin/organize run >> /var/log/organize/organize.log 2>&1 && exit 0
  fi

Many thanks ..

@nodecentral
Copy link
Author

Ok, some progress, while I can’t achieve this with the docker_compose.yml, I have has some success with the following Docker run

docker run -dit --rm --name organize \
	  -v "/share/Container/organize/config/":/home/pi/.config/organize/ \
	  -v "/share/Container/organize/logs/":/var/log/organize/ \
	  -v "/share/Container/organize/input/":/Input \
	  -v "/share/Container/organize/output/":/Output \
	  -v "/share/Publications/":/Publications \
	  -v "/share/Movies/":/Movies \
	  docker-organize \
	   "* * * * *"

I tool the “* * * * “ aspect from another docker run I had - so if anyone can explain the difference between the above and the following compose - please let me know..

version: '3'
services: 
  docker-organize:
    image: docker-organize:latest
    container_name: organize
    volumes:
      - /share/Container/organize/output:/Output
      - /share/Container/organize/input:/Input
      - /share/Container/organize/logs:/var/log/organize/
      - /share/Container/organize/config:/home/pi/.config/organize/
      - /share/Publications:/Publications
      - /share/Container:/Containers
      - /share/Movies:/Movies

@tfeldmann
Copy link
Owner

Thanks for describing the problem. If I understand it correctly you'd like to keep organize running in the background to watch for any changes in the given locations? Maybe something like #18?
This is one of the next features planned for the upcoming releases.

allowing me to then interact with it via the command line so I can run many different config.yml files I have?

Can you elaborate on that? What would this interactive mode look like?

@nodecentral
Copy link
Author

nodecentral commented Mar 25, 2024

Hi @tfeldmann , thanks so much for responding.

I was not necessarily thinking about watching for something like a folder update, although I can see the benefit there - my uses case is that I have created a number of very focussed config.yml files - that do specific things when I want to run them.

Some times I need to do one thing first to sort stuff out and another to move things around into other folders - yes they can be run in sequence - but the order is not always easy to prescribe or I just want to run one or two on demand.

I don’t recall seeing a UI for Organize, but having it run constantly allows me to explore options like a command line menu of some sort - or I can maybe make calls to run Organize scripts from other systems.

@tfeldmann
Copy link
Owner

Ok starting with v3 you can already do this:

organize new name1
organize new name2
organize run name1
organize run name2

Maybe you can define some aliases to make this even shorter? Something like alias orun='organize run'?

tfeldmann added a commit that referenced this issue Mar 28, 2024
@tfeldmann
Copy link
Owner

I'll close this issue but will add "Improve CLI documentation" to my todo list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants