summaryrefslogtreecommitdiff
path: root/src/backend/updateAll.py
blob: d7d120363487b4070c6e3f8ed37da554d3174e54 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python3

import animation
import sys
import time
import sisyphus.checkenv
import sisyphus.getenv
import sisyphus.purgeenv
import sisyphus.syncDatabase
import sisyphus.syncEnvironment

def syncAll():
    sisyphus.purgeenv.cache()
    sisyphus.syncEnvironment.gentooRepo()
    sisyphus.syncEnvironment.redcoreRepo()
    sisyphus.syncEnvironment.portageConfigRepo()
    sisyphus.syncDatabase.remoteTable()

@animation.wait('fetching updates')
def cliExec():
    activeBranch = sisyphus.checkenv.branch()
    binhostURL = sisyphus.getenv.binhostURL()
    isSane = sisyphus.checkenv.sanity()

    if isSane == 1:
        syncAll()
    else:
        if "packages-next" in binhostURL:
            print("\nCurrent branch: '" + activeBranch + "' (stable)" + "\nCurrent binhost: '" + binhostURL + "' (testing)")
        else:
            print("\nCurrent branch: '" + activeBranch + "' (testing)" + "\nCurrent binhost: '" + binhostURL + "' (stable)")
        sys.exit("\nInvalid branch - binhost pairing; Use 'sisyphus branch --help' for help; Quitting.")

def guiExec():
    activeBranch = sisyphus.checkenv.branch()
    binhostURL = sisyphus.getenv.binhostURL()
    isSane = sisyphus.checkenv.sanity()

    if isSane == 1:
        syncAll()
    else:
        if "packages-next" in binhostURL:
            print("\nCurrent branch: '" + activeBranch + "' (stable)" + "\nCurrent binhost: '" + binhostURL + "' (testing)")
        else:
            print("\nCurrent branch: '" + activeBranch + "' (testing)" + "\nCurrent binhost: '" + binhostURL + "' (stable)")
        print("\nInvalid branch - binhost pairing; Use 'sisyphus branch --help' for help; Quitting in 10 seconds.\n")
        t = int(10)
        while t:
            mins, secs = divmod(t, 60)
            timer = '{:02d}:{:02d}'.format(mins, secs)
            print(timer, end="\r")
            time.sleep(1)
            t -= 1

        sys.exit()