summaryrefslogtreecommitdiff
path: root/src/backend/getenv.py
blob: eebbfee2ad8f9b7617fcfde2e0bcc53ee68e60ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/python3

import io
import subprocess


def binhostURL():
    binhostURL = []
    portageExec = subprocess.Popen(
        ['emerge', '--info', '--verbose'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"):
        if "PORTAGE_BINHOST" in portageOutput:
            binhostURL = portageOutput.rstrip().split("=")[1].strip('\"')

    portageExec.wait()
    return binhostURL


def csvURL():
    csvURL = binhostURL()
    packagesCsvURL = []
    descriptionsCsvURL = []

    if "packages-next" in csvURL:
        packagesCsvURL = csvURL.replace(
            'packages-next', 'csv-next') + 'remotePackagesPre.csv'
        descriptionsCsvURL = csvURL.replace(
            'packages-next', 'csv-next') + 'remoteDescriptionsPre.csv'
    else:
        packagesCsvURL = csvURL.replace(
            'packages', 'csv') + 'remotePackagesPre.csv'
        descriptionsCsvURL = csvURL.replace(
            'packages', 'csv') + 'remoteDescriptionsPre.csv'

    return packagesCsvURL, descriptionsCsvURL