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

check and convert command line parameter for windows #9

Open
gitnol opened this issue May 21, 2022 · 0 comments
Open

check and convert command line parameter for windows #9

gitnol opened this issue May 21, 2022 · 0 comments

Comments

@gitnol
Copy link

gitnol commented May 21, 2022

Hi,

On windows, an error occurs in mitmproxy2swagger.py line 63 because yaml.load(f) does not like the backslash in the f string (the input parameter -o)

with open(args.output, 'r') as f:

mitmproxy2swagger -i "D:\Downloads\flows" -o "D:\Downloads\flows_schema.yml" -p https://my.site.com

If you change it to a slash, there is no problem and it works like intended.
mitmproxy2swagger -i "D:/Downloads/flows" -o "D:/Downloads/flows_schema.yml" -p https://my.site.com

Therefore, my suggestion/solution is to replace '' with '/'

import os
args.output = arg.output.replace(os.sep, '/')
args.input = args.input.replace(os.sep, '/')

Traceback:

Traceback (most recent call last):
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\Scripts\mitmproxy2swagger.exe\__main__.py", line 7, in 
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\mitmproxy2swagger\mitmproxy2swagger.py", line 63, in main
    swagger = yaml.load(f)
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\main.py", line 434, in load
    return constructor.get_single_data()
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\constructor.py", line 119, in get_single_data
    node = self.composer.get_single_node()
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\composer.py", line 76, in get_single_node
    document = self.compose_document()
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\composer.py", line 99, in compose_document
    node = self.compose_node(None, None)
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\composer.py", line 143, in compose_node
    node = self.compose_mapping_node(anchor)
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\composer.py", line 223, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\composer.py", line 141, in compose_node
    node = self.compose_sequence_node(anchor)
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\composer.py", line 184, in compose_sequence_node
    while not self.parser.check_event(SequenceEndEvent):
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\parser.py", line 146, in check_event
    self.current_event = self.state()
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\parser.py", line 565, in parse_indentless_sequence_entry
    if not self.scanner.check_token(
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\scanner.py", line 1794, in check_token
    while self.need_more_tokens():
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\scanner.py", line 211, in need_more_tokens
    self.stale_possible_simple_keys()
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python310\lib\site-packages\ruamel\yaml\scanner.py", line 360, in stale_possible_simple_keys
    raise ScannerError(
ruamel.yaml.scanner.ScannerError: while scanning a simple key
  in "D:\Downloads\flows_schema.yml", line 86, column 1
could not find expected ':'
  in "D:\Downloads\flows_schema.yml", line 87, column 1
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

1 participant