GithubHelp home page GithubHelp logo

Comments (6)

GiorgosXou avatar GiorgosXou commented on May 18, 2024

Silly of me running another subprocess on top of another thinking that the first one would had been terminated somehow (or whatever the fuck i was thinking that time).

Issue

It's more of a "how to restore the terminal after opening&closing a subprocess" issue rather than anything else. Somehow after such a sequence (of opening&closing) things can get messed up, especially keys and the mode of terminal [...]

A potential solution

A temporary but also potential solution could be os.exec*()

from tuifimanager.

GiorgosXou avatar GiorgosXou commented on May 18, 2024

Yep, so far (the temp solution) works as expected
Screenshot_2022-02-14-14-26-46-749_com termux
(Image: termux)

from tuifimanager.

GiorgosXou avatar GiorgosXou commented on May 18, 2024

Actually this line os.execl(sys.argv[0], sys.argv[0], self.directory) does the job (I'm not sure why sys.argv[0] needs to be pressent 2 times)

from tuifimanager.

GiorgosXou avatar GiorgosXou commented on May 18, 2024

Also just a reminder to add

if unicurses.OPERATING_SYSTEM != 'Windows': 
    os.system('stty sane')

Or something like that anyways

from tuifimanager.

GiorgosXou avatar GiorgosXou commented on May 18, 2024

I just found out that os.execl(sys.argv[0], sys.argv[0], self.directory) works only if pip3 install . the setup.py and not if I just run python3 ...\__main__.py with:

import sys                                               
from os.path import dirname, abspath    
sys.path.insert(0, dirname(dirname(abspath(__file__))))

from tuifimanager.

GiorgosXou avatar GiorgosXou commented on May 18, 2024

Here another very intresting solution i found out:

    @staticmethod
    @contextmanager
    def suspend():
        """
        Suspend curses in order to open another subprocess in the terminal.
        """

        try:
            curses.endwin()
            yield
        finally:
            curses.doupdate()
def open(...):
   ...
            if open_with:
                with self.suspend():
                    os.system('clear')
                    proc = subprocess.Popen([open_with, directory])
                    proc.wait()

Althought I've no idea of how it works

from tuifimanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.