Skip to content

Change hard coded /tmp to cross-platform tempfile #148

@kazoob

Description

@kazoob

Pardon me as I am not a Python expert. I installed Python and python-miio on Windows. When running the following command:

mirobo status

I received the following errors in addition to the proper output:

ERROR:miio.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or
directory: '/tmp/python-mirobo.seq'
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 3
State: Charging
Battery: 93 %
Fanspeed: 60 %
Cleaning since: 0:10:25
Cleaned area: 4.71 m²
Traceback (most recent call last):
File "c:\python\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\python\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Python\Scripts\mirobo.exe_main
.py", line 9, in
File "c:\python\lib\site-packages\click\core.py", line 722, in call
return self.main(*args, **kwargs)
File "c:\python\lib\site-packages\click\core.py", line 697, in main
rv = self.invoke(ctx)
File "c:\python\lib\site-packages\click\core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\python\lib\site-packages\click\core.py", line 1031, in _process_resul
t
**ctx.params)
File "c:\python\lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "c:\python\lib\site-packages\click\decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "c:\python\lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "c:\python\lib\site-packages\miio\vacuum_cli.py", line 98, in cleanup
with open(id_file, 'w') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'

As a test I modified the following line in "vacuum_cli.py" from:

@click.option('--id-file', type=click.Path(dir_okay=False, writable=True), default='/tmp/python-mirobo.seq')

To:

@click.option('--id-file', type=click.Path(dir_okay=False, writable=True), default='c:\\python-mirobo.seq')

And now it works fine!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions