Skip to main content

GNU-Screen session module handler for NodeJs

Project description

What is this ?

This was build to handle and manage gnu-screen session. Actually work well.

Table of Contents

Required

  • Python: 3.8
  • GNU-Screen: 4.08.00

Installation

First make sure you have gnu-screen installed:

$ apt-get install screen

To run this project, use pip:

$ pip install gnu-screen

Functions

  • getAll() Return all available Screens.

Screen

Create a representation of gnu-screen session : Screen(id, mode="") If you want to save logs change mode to 's'.

Events:

  • close When screen is closed.
  • stdout str When something new is append in logFile.

Methods:

  • Screen.exist() Check if screen's session is running.
  • Screen.setup() Fetch self variable with running session.
  • Screen.setRule(*rules) Rules to apply in screen session.
  • Screen.write(*stdins) Write something in screen session.
  • Screen.setStdout(state) Watch over logFile to call stdout Event.
  • Screen.logFile() Return logFile.
  • Screen.on(call) Set an event (disconnect(),close(),stdout(log)).
  • Screen.run(stdin=None) Connect/create to screen session.
  • Screen.close() Close screen session.
  • Screen.kill(signal=15) Kill screen session.

KeyValues:

  • Screen.id str | None Screen session's id.
  • Screen.logFilePath str | None Path of logFile is there one.
  • Screen.events dict Screen session events.
  • Screen.pid int | None Pid of screen session if is running.
  • Screen.date str | None Date of screen session if is running.
  • Screen.state str | None State of screen session if is running.

Exemple

import os
import gnu_screen as sc

# Generate 10 screens session
for n in range(10):
    scr = sc.Screen(id=f"test n°{n}")
    print(scr)
    scr.run()

# Find and close the 10 screens session
for scr in sc.getAll():
    print(scr)
    scr.close()

# Create a new screen session
test = sc.Screen(id="final test", mode="r")
test.run()
print(test)

# Allow "stdout" event
test.setStdout()


# Remove screen session
def close():
    test.close()
    if not test.pid:
        print("Closed final test's screen session")
    else:
        test.kill()
        print("Killed test's screen session")
    #self kill
    os.kill(os.getpid(), 15)


# Get stdout from screen session
@test.on
def stdout(log):
    print("stdout:", log)
    if "!close" in log:
        close()


# Pipe input to the screen session
while test.pid:
    try:
        test.write(input())
    except KeyboardInterrupt:
        # Capture Ctrl + C to close screen session
        close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gnu-screen-0.0.8.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distributions

gnu_screen-0.0.8-py3.8.egg (8.3 kB view hashes)

Uploaded Source

gnu_screen-0.0.8-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page