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

pip3 install of l2tscaffolder is missing the ".style.ts.yapf" file #81

Open
jkppr opened this issue Jun 2, 2022 · 4 comments
Open

pip3 install of l2tscaffolder is missing the ".style.ts.yapf" file #81

jkppr opened this issue Jun 2, 2022 · 4 comments
Assignees

Comments

@jkppr
Copy link
Contributor

jkppr commented Jun 2, 2022

Describe the bug

When running l2t_scaffolder.py to create the setup for a new timesketch analyzer the tool crashes because it cannot find the .style.ts.yap style file.
It looks like installing l2tscaffolder via pip3 install l2tscaffolder does not place the .style.ts.yap file in the expected place ~/.local/lib/python3.9/site-packages/l2tscaffolder/.style.ts.yapf. After copying the file there manually from github, it works without issues.

To Reproduce

Steps to reproduce the behavior:

  1. Make a fresh install via pip3 install l2tscaffolder
  2. Run via l2t_scaffolder.py
  3. Select [1] timesketch, provide . as path, select [1] sketch_analyzer
  4. Error output:
$ cd ~/timesketch
$ l2t_scaffolder.py
   == Starting the scaffolder ==
Gathering required information.

Available definitions: 
  [0] plaso
  [1] timesketch
  [2] turbinia
Definition choice: 1
timesketch chosen.

Path to the project root: .
Path [.] set as the project path.

Name of the module to be generated. This can be something like "foobar sqlite" or "event analytics".

This will be used for class name generation and file name prefixes.
Module Name: screenshot_test
About to create a new feature branch to store newly generated code.
Switching to feature branch screenshot_test

Available scaffolders for timesketch:
  [0] index_analyzer
  [1] sketch_analyzer
Scaffolder choice: 1
Ready to generate files? [Y/n]:
Traceback (most recent call last):
  File "~/.local/bin/l2t_scaffolder.py", line 26, in <module>
    StartCLI()  # pylint: disable=no-value-for-parameter
  File "~/.local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "~/.local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "~/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "~/.local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "~/.local/bin/l2t_scaffolder.py", line 22, in StartCLI
    cli.Start(definition)
  File "~/.local/lib/python3.9/site-packages/l2tscaffolder/frontend/frontend.py", line 375, in Start
    for file_path in scaffolder_engine.GenerateFiles():
  File "~/.local/lib/python3.9/site-packages/l2tscaffolder/lib/engine.py", line 74, in GenerateFiles
    for file_path, content in self._scaffolder.GenerateFiles():
  File "~/.local/lib/python3.9/site-packages/l2tscaffolder/scaffolders/timesketch.py", line 103, in GenerateFiles
    plugin_content = self._GeneratePlugin()
  File "~/.local/lib/python3.9/site-packages/l2tscaffolder/scaffolders/timesketch.py", line 54, in _GeneratePlugin
    return self._mapping_helper.RenderTemplate(
  File "~/.local/lib/python3.9/site-packages/l2tscaffolder/lib/mapping_helper.py", line 124, in RenderTemplate
    formatted = self.formatter.Format(template)[0]
  File "~/.local/lib/python3.9/site-packages/l2tscaffolder/lib/code_formatter.py", line 28, in Format
    return yapf_api.FormatCode(code, style_config=self.yapf_path)
  File "~/.local/lib/python3.9/site-packages/yapf/yapflib/yapf_api.py", line 124, in FormatCode
    style.SetGlobalStyle(style.CreateStyleFromConfig(style_config))
  File "~/.local/lib/python3.9/site-packages/yapf/yapflib/style.py", line 498, in CreateStyleFromConfig
    config = _CreateConfigParserFromConfigFile(style_config)
  File "~/.local/lib/python3.9/site-packages/yapf/yapflib/style.py", line 527, in _CreateConfigParserFromConfigFile
    raise StyleConfigError(
yapf.yapflib.style.StyleConfigError: "~/.local/lib/python3.9/site-packages/l2tscaffolder/.style.ts.yapf" is not a valid style or file path

Expected behavior

Instead of crashing I would expect l2tscaffolder to create the required files. Expected output:

[...]
Ready to generate files? [Y/n]: 
File: ./timesketch/lib/analyzers/screenshot_test_2.py written to disk.
File: ./timesketch/lib/analyzers/screenshot_test_2_test.py written to disk.
File: ./timesketch/lib/analyzers/__init__.py written to disk.

Desktop (please complete the following information):

  • OS: Debian
  • Version 5.17.6-1rodete1 (2022-05-12)

l2tscaffolder Version

$ pip3 list | grep l2tscaffolder
l2tscaffolder               20200511
@studiawan
Copy link
Contributor

I have the same issue. Any idea how to solve this issue?

@jkppr
Copy link
Contributor Author

jkppr commented Jun 7, 2022

@studiawan you can try one of the following workarounds that worked for me to get l2tscaffolder running:

  • Just download and copy the missing file .style.ts.yapf into the location from the error message. E.g. ~/.local/lib/python3.9/site-packages/l2tscaffolder/.style.ts.yapf
  • Install l2tscaffolder from source as documented here.

@studiawan
Copy link
Contributor

studiawan commented Jun 7, 2022

Hi @jkppr, I have successfully installed l2tscaffolder from source. However, we do not need to add the missing .yapf file as it has been already provided in the repository.

Thanks!

@joachimmetz
Copy link
Member

@Onager can you PTAL, I assume the file is missing from MANIFEST.in

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

No branches or pull requests

4 participants