aboutcode-org/aboutcode-toolkit

About gen error

Closed this issue · 4 comments

mire22 commented

Hi,

I would like to use about in combination with scancode but i'm struggling with errors...

Environment:

  • Windows 10
  • Python 3.7.6
  • ScanCode version: 32.0.6
  • ScanCode Output Format version: 3.0.0
  • SPDX License list version: 3.21
  • AboutCode-toolkit version 9.0.0 (installed via this wheel file)
  • ABOUT spec version: 3.3.1

I'm generating the scancode report on the "samples" folder that is provided with scancode-toolkit:
scancode -clpieu --json output.json samples which generates the json file:
output.json.txt
I prepared a conf.txt file to transform path field to about_resource:
conf.txt
Then I ran the transform command:
about transform -c conf.txt output.json output_t.json and got the file:
output_t.json.txt
Then I ran the gen command:
about gen output_t.json samples/
And got the following error:
`Running aboutcode-toolkit version 9.0.0

Generating .ABOUT files...

Traceback (most recent call last):

File "c:\users\h3\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)

File "c:\users\h3\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)

File "C:\Users\h3\Anaconda3\Scripts\about.exe_main_.py", line 7, in

File "c:\users\h3\anaconda3\lib\site-packages\click\core.py", line 764, in call
return self.main(*args, **kwargs)

File "c:\users\h3\anaconda3\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)

File "c:\users\h3\anaconda3\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))

File "c:\users\h3\anaconda3\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)

File "c:\users\h3\anaconda3\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)

File "c:\users\h3\anaconda3\lib\site-packages\attributecode\cmd.py", line 281, in gen
worksheet=worksheet

File "c:\users\h3\anaconda3\lib\site-packages\attributecode\gen.py", line 297, in generate
worksheet=worksheet

File "c:\users\h3\anaconda3\lib\site-packages\attributecode\gen.py", line 148, in load_inventory
inventory = load_json(location)

File "c:\users\h3\anaconda3\lib\site-packages\attributecode\util.py", line 281, in load_json
results = sorted(results)

TypeError: '<' not supported between instances of 'dict' and 'dict'`

Can you help me solve this error?

Thank you!

Best regards,
Rémi

@mire22 Thanks for entering the issue. The issue is about that dictionaries are no longer orderable in python 3, so it will return error when trying to use the "sorted" function. This issue is fixed in the latest develop branch. However, because #518 is not fixed yet, the gerenated ABOUT files may not look nice (I will tackle this soon).

@mire22 FYI, version 10.0.0 is released and the issue should be fixed. Note that if the input is from scancode-toolkit, you don't need to do transform, but use the --scancode option instead.

mire22 commented

@chinyeungli Thanks, it worked!

Additionnal questions (I can create a new issue if you prefer) :

  • When I'm running about gen --scancode --fetch-license output.json output i get the following error ERROR: Network problem. Please check your Internet connection. License generation is skipped.. I think it's because I need to specify my proxy. Is there a way to do that?
  • What is the option to choose what fields to get in the .ABOUT files? For example, I don't want the size_count, sha1 or the start_line / end_line...

Thank you!

@mire22 Thanks for testing it.

What is the option to choose what fields to get in the .ABOUT files? For example, I don't want the size_count, sha1 or the start_line / end_line...

You will need to use the transform to filter out the unwanted fields. For instance,

exclude_fields:
   - start_line
   - end_line

About the proxy issue. Sorry as I don't have a proxy-needed environment to test it. Can you try with this branch: https://github.com/nexB/aboutcode-toolkit/tree/533_proxy_setting
I've updated the code to use requests library to do the http request where users can set the standard environment variables http_proxy, https_proxy, no_proxy, and all_proxy
i.e.

$ export HTTP_PROXY="http://10.10.1.10:3128"
$ export HTTPS_PROXY="http://10.10.1.10:1080"
$ export ALL_PROXY="socks5://10.10.1.10:3434"

(https://requests.readthedocs.io/en/latest/user/advanced/#proxies)
Please let me know if this works so that I can push a new release.
Thanks in advance.