tfeldmann/organize

TypeError: cannot unpack non-iterable NoneType object

Closed this issue · 9 comments

Using windows 10 I followed these instructions to install https://organize.readthedocs.io/en/latest/

I then used the default config file to test my install was working.

rules:
  - name: "Find PDFs"
    locations:
      - ~/Downloads
    subfolders: true
    filters:
      - extension: pdf
    actions:
      - echo: "Found PDF!"

organize check returns

organize check
Checking: C:\Users\shill\AppData\Local\organize\config.yaml
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\shill\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCac │
│ he\local-packages\Python38\site-packages\organize\cli.py:280 in check                            │
│                                                                                                  │
│   277 │   │   │   out.print("\n\n")                                                              │
│   278 │   │   │   out.rule("Migration from v1", align="left")                                    │
│   279 │   │                                                                                      │
│ ❱ 280 │   │   migration.migrate_v1(rules)                                                        │
│   281 │   │                                                                                      │
│   282 │   │   if debug:                                                                          │
│   283 │   │   │   out.print("Not needed.")                                                       │
│                                                                                                  │
│ C:\Users\shill\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCac │
│ he\local-packages\Python38\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

Even the minimum config from https://organize.readthedocs.io/en/latest/rules/ does not work

rules:
  locations: "~/Desktop"
    actions:
      - echo: "Hello World!"

Well this is odd. I get the same error message even if the file doesn't exist. It's almost as though organize is not reading my config file at all. If I fill the file with random data, same error.

File permissions are correct, path is correct: C:\Users\shill\AppData\Local\organize\config.yaml

C:\Users\shill\Downloads>organize reveal --path
C:\Users\shill\AppData\Local\organize\config.yaml

I'm at a loss. Can anyone help?

I was reading the source code and config.cleanup() should throw an exception for an empty config file. This is not happening.

I couldn't reproduce on my machine. Can you upload your config file so it keeps all the formatting?

Hi @kamuridesu

Here is the config file, located at C:\Users\Stephen\AppData\Local\organize\config.yaml
config.zip

I've tried installing and running organize on another Windows 10 machine, this time using Python 3.11. Exactly the same problem.

C:\Users\Stephen>organize check
Checking: C:\Users\Stephen\AppData\Local\organize\config.yaml
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\Stephen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\Local │
│ Cache\local-packages\Python311\site-packages\organize\cli.py:280 in check                        │
│                                                                                                  │
│   277 │   │   │   out.print("\n\n")                                                              │
│   278 │   │   │   out.rule("Migration from v1", align="left")                                    │
│   279 │   │                                                                                      │
│ ❱ 280 │   │   migration.migrate_v1(rules)                                                        │
│   281 │   │                                                                                      │
│   282 │   │   if debug:                                                                          │
│   283 │   │   │   out.print("Not needed.")                                                       │
│                                                                                                  │
│ C:\Users\Stephen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\Local │
│ Cache\local-packages\Python311\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

I will note that organize does not create the config directory for me, I had to manually create C:\Users\Stephen\AppData\Local\organize and then add the config file myself.

I also tried it on Alpine Linux 3.17.2 with Python 3.10. That also comes up with the same error.

stephen@stephen ~ [1]> organize run
organize 2.4.0
Config: "/home/stephen/.config/organize/config.yaml"
Working dir: ""
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /usr/lib/python3.10/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/lib/python3.10/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/lib/python3.10/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

I don't know Python development very well, but I was looking through one of the CI test results and noticed that the CI scripts appear to install more dependencies. For instance, setuptools and poetry are installed, which download more dependencies.

Is it possible there is a dependency missing from a normal pip3 install?

@kamuridesu Ignore part of the above, it is working on Alpine Linux.

But still not working on Windows 10, so this appears to be a windows issue of some sort.

Let's try something:

Try to use another file, in your Documents folder, with organize sim [FILE].

@kamuridesu Yes, that works.

C:\Users\shill\Downloads>organize sim
organize 2.4.0
Config: "C:\Users\shill\AppData\Local\organize\config.yaml"
Working dir: ""
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\shill\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCac │
│ he\local-packages\Python38\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,                                                       │
│                                                                                                  │
│ C:\Users\shill\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCac │
│ he\local-packages\Python38\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)                                                             │
│                                                                                                  │
│ C:\Users\shill\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCac │
│ he\local-packages\Python38\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

C:\Users\shill\Downloads>organize sim custom.yaml
organize 2.4.0
Config: "C:\Users\shill\Downloads\custom.yaml"
Working dir: ""

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮│ SIMULATION
               │╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
⚙ Find PDFs ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────/C:\Users\shill\Downloads\
  xxx.pdf
    - (echo) Found PDF!
  xxx.pdf
    - (echo) Found PDF!

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮│ SIMULATION
               │╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
success 2 / fail 0

Both C:\Users\shill\AppData\Local\organize\config.yaml and C:\Users\shill\Downloads\custom.yaml have the same contents. The first command fails, the second command (specifying the config file) runs correctly.

Also interesting it that organize sim C:\Users\shill\AppData\Local\organize\config.yaml does not work either.

Thank you for the work around, I'll use the for now.