mirror of
https://github.com/gryf/fs-uae-wrapper.git
synced 2026-02-02 14:15:45 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b0ef15eae |
18
fs_uae_wrapper/nogui_message.py
Normal file
18
fs_uae_wrapper/nogui_message.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
"""
|
||||||
|
Display message as simple text on console
|
||||||
|
"""
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
class Message:
|
||||||
|
"""Just a fake message window for systems without TK"""
|
||||||
|
|
||||||
|
def __init__(self, msg):
|
||||||
|
self.msg = msg
|
||||||
|
self._process = None
|
||||||
|
|
||||||
|
def show(self):
|
||||||
|
sys.stdout.write(self.msg + "\n")
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
return None
|
||||||
@@ -8,7 +8,11 @@ import pathlib
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from fs_uae_wrapper import file_archive, message
|
from fs_uae_wrapper import file_archive
|
||||||
|
try:
|
||||||
|
from fs_uae_wrapper.message import Message
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
from fs_uae_wrapper.nogui_message import Message
|
||||||
|
|
||||||
|
|
||||||
class CmdOption(dict):
|
class CmdOption(dict):
|
||||||
@@ -64,7 +68,7 @@ def operate_archive(arch_name, operation, text, params):
|
|||||||
if archiver is None:
|
if archiver is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
msg = message.Message(text)
|
msg = Message(text)
|
||||||
if text:
|
if text:
|
||||||
msg.show()
|
msg.show()
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import os
|
|||||||
from unittest import TestCase, mock
|
from unittest import TestCase, mock
|
||||||
|
|
||||||
from fs_uae_wrapper import message
|
from fs_uae_wrapper import message
|
||||||
|
from fs_uae_wrapper import nogui_message
|
||||||
|
|
||||||
if os.environ.get('DISPLAY'):
|
if os.environ.get('DISPLAY'):
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
@@ -38,6 +39,19 @@ class TestMessage(TestCase):
|
|||||||
msg._process.join.assert_called_once()
|
msg._process.join.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
class TestNOPMessage(TestCase):
|
||||||
|
|
||||||
|
@mock.patch('sys.stdout.write')
|
||||||
|
def test_show(self, stdout_write):
|
||||||
|
msg = nogui_message.Message('display that')
|
||||||
|
msg.show()
|
||||||
|
stdout_write.assert_called_once()
|
||||||
|
|
||||||
|
def test_close(self):
|
||||||
|
msg = nogui_message.Message('display that')
|
||||||
|
self.assertIsNone(msg.close())
|
||||||
|
|
||||||
|
|
||||||
if os.environ.get('DISPLAY'):
|
if os.environ.get('DISPLAY'):
|
||||||
# Tkinter needs graphic environment for the widgets
|
# Tkinter needs graphic environment for the widgets
|
||||||
class TestSpawn(TestCase):
|
class TestSpawn(TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user