Beispiel #1
0
def setup(wm):


        mouseEvents = []
        mouseEvents.append(MouseEvent(3, ModKey, wm.resizer.mouseActivate, wm.resizer.mouseDeactivate, wm.resizer.mouseMotion))
        mouseEvents.append(MouseEvent(1, ModKey, wm.mover.mouseActivate, wm.mover.mouseDeactivate, wm.mover.mouseMotion))

        keyEvents = []

        keyEvents.append(KeyEvent(Xlib.XK.XK_Return, ModKey, lambda e: bash.run('urxvtc')))
        keyEvents.append(KeyEvent(Xlib.XK.XK_C, ModKey, lambda e: bash.run('firefox')))
        keyEvents.append(KeyEvent(Xlib.XK.XK_P, ModKey, lambda e: bash.run('thunar')))


        keyEvents.append(KeyEvent(Xlib.XK.XK_R, ModKey, wm.gotoTrayRun))
        keyEvents.append(KeyEvent(Xlib.XK.XK_Q, ModKey, wm.killCurrentFrame))
        keyEvents.append(KeyEvent(Xlib.XK.XK_F, ModKey, wm.fullscreenCurrentFrame))

        keyEvents.append(KeyEvent(Xlib.XK.XK_U, ModKey, wm.navParent))
        keyEvents.append(KeyEvent(Xlib.XK.XK_N, ModKey, wm.navLeftUp))
        keyEvents.append(KeyEvent(Xlib.XK.XK_I, ModKey, wm.navRightDown))

        keyEvents.append(KeyEvent(Xlib.XK.XK_E, ModKey, wm.grabReleaseFrame))

        keyEvents.append(KeyEvent(Xlib.XK.XK_N, ModKey | SizeKey, wm.resizer.keyLeftUp))
        keyEvents.append(KeyEvent(Xlib.XK.XK_I, ModKey | SizeKey, wm.resizer.keyRightDown))

        for i in xrange(0, 9):
            keyEvents.append(KeyEvent(i + Xlib.XK.XK_1, ModKey, wm.switchSpaces))

        return mouseEvents, keyEvents
Beispiel #2
0
def read_file(master_password, filename=""):
    """Opens filename and returns it as a string"""
    bash.run('touch "%s" ]' % (filename,), False)
    ret = bash.run('cat "%s" | aescrypt -d -p "%s" -o - -' \
            % (master_password, filename,), False)
    if ret.return_code_success():
        return ret.stdout()
    else:
        print("Decryption failed.  Did you enter the wrong master password?")
        return ""
Beispiel #3
0
 def keypress(self, key):
     if self.cmdMode:
         if key > 0 and key < 256:
             self.text += chr(key)
         elif key == XK_BackSpace:
             self.text = self.text[:-1]
         elif key == XK_Return:
             bash.run(self.text)
             self.text = ''
             self.exitCmdMode()
         elif key == XK_Escape:
             self.text = ''
             self.exitCmdMode()
         
         self.redraw()
Beispiel #4
0
import bash

bash.run('mkswap', '/mnt/gentoo/var/.32GiB.swp')
Beispiel #5
0
import bash

bash.run('mount', '-o rw,acl,active_logs=6,background_gc=on,user_xattr -t f2fs /dev/nvme0n1p5 /mnt/MANJARO')
bash.run('mount', '-t vfat /dev/disk/by-label/ESP /mnt/MANJARO/boot/')
bash.run('cp'   , '--dereference /etc/resolv.conf /mnt/MANJARO/etc/')
bash.run('mount', '--types proc /proc /mnt/MANJARO/proc')
bash.run('mount', '--rbind /sys /mnt/MANJARO/sys')
bash.run('mount', '--make-rslave /mnt/MANJARO/sys')
bash.run('mount', '--rbind /dev /mnt/MANJARO/dev')
bash.run('mount', '--make-rslave /mnt/MANJARO/dev')
bash.run('test' , '-L /dev/shm ')
bash.run('rm'   , '/dev/shm')
bash.run('mkdir', '/dev/shm')
bash.run('mount', '-t tmpfs -o nosuid,nodev,noexec shm /dev/shm')
bash.run('chmod', '1777 /dev/shm')



# livecd /mnt/gentoo # mount -t proc /proc /mnt/gentoo/proc
# livecd /mnt/gentoo # mount --rbind /sys /mnt/gentoo/sys
# livecd /mnt/gentoo # mount --make-rslave /mnt/gentoo/sys
# livecd /mnt/gentoo # mount --rbind /dev /mnt/gentoo/dev
# livecd /mnt/gentoo # mount --make-rslave /mnt/gentoo/dev
# livecd /mnt/gentoo # test -L /dev/shm && rm /dev/shm && mkdir /dev/shm
# livecd /mnt/gentoo # mount -t tmpfs -o nosuid,nodev,noexec shm /dev/shm
# livecd /mnt/gentoo # chmod 1777 /dev/shm
Beispiel #6
0
def write_file(contents, master_password, filename=DEFAULT_FILE_NAME):
    """Writes the content to filename"""
    ret = bash.run('echo "%s" | aescrypt -e -p "%s" -o "$HOME/%s" -' \
            % (contents, master_password, filename,), False)
    if not ret.return_code_success():
        print('saving master keyfile failed!: %s' % (ret.stderr(),))
Beispiel #7
0
def test_run(run):
    c = run("echo hi")
    assert c.ok
    assert "hi" in c.output
Beispiel #8
0
def mount():
    bash.run(
        'sudo',
        '-S mount -o rw,acl,active_logs=6,background_gc=on,user_xattr -t f2fs /dev/disk/by-label/GENTOO /mnt/gentoo'
    )

    #mkfs.btrfs -L USERDATA -n 32k /dev/nvme0n1p4)
    bash.run('mkdir', '/mnt/gentoo/boot')
    bash.run('mkdir', '/mnt/gentoo/var')
    bash.run('mount', '-t vfat /dev/disk/by-label/ESP /mnt/gentoo/boot/')

    #bash.run('dd', f'status=progress if=/dev/zero bs=4096 of=/mnt/gentoo/var/.32GiB.bin bs=4096 count={32 * cGiB}')
    bash.run('chmod', '600 /mnt/gentoo/var/.32GiB.swp')
    bash.run('mkswap', '/mnt/gentoo/var/.32GiB.swp')
Beispiel #9
0
def fsformat():
    bash.run(
        'mkfs.f2fs',
        f'-f -l {LABEL["ROOT"]} -O extra_attr,inode_checksum,sb_checksum /dev/{CFG["STOR"]["ROOT"]}'
    )
Beispiel #10
0
def wipe(file=f'/dev/{STOR["DEV"]}'):
    bash.run('dd', f'if=/dev/zero of={file}  bs=100M status=progress')
Beispiel #11
0
def prepare():
    prop.set(CFG['PASSWDQC'], {'enforce': 'none'})
    bash.run('passwd', f'{PW["ROOT"]}')
    bash.run('rc-service', f'sshd start')
Beispiel #12
0
	def sh_query(self, command):
		""" Send bash query, only return result """
		res, err = bash.run(command)
		return res
Beispiel #13
0
	def sh_command(self, command):
		""" Send bash command """
		return bash.run(command)
def logon():
    # If the prompt.bws file doesn't exist, call on repair script to initialize one.
    if (os.path.exists("prompt.bws") == False):
        if (repair.promptInit(os.getcwd()) == 1):
            os.system("cls")
            print(
                "Bash for Windows has run into a non-critical error:\nPROMPT_NOT_ACCESSABLE\n\n\
This is not a critical error, so Bash for Windows will continue to work ok,\nminus some optional \
functionality.")
            choice = input(
                "Do you want to contnue using Bash for Windows? [y,N] ")
            if (choice.upper() != "Y"):
                exit(1)
            # Initialize variables with default values
            systemvariables.init("debugMsg", 0)
            systemvariables.init("varTrans", 0)
            systemvariables.init("colorPrompt", 0)
    else:
        # Check again to make sure we are running Windows
        oschk.check()

        os.chdir(systemvariables.read("exepath"))
        os.chdir("../../")
        incorrect = True
        while (incorrect == True):
            user = open("Settings/ivhzadgz.bws", "r")
            userguess = input(socket.gethostname() + " login: "******"Incorrect Username.")
        incorrect = True

        # Check double check to make sure we are running Windows
        if (platform.system() != "Windows"):
            print(
                "Bash for Windows has seen that you are not using Windows. Launching Bash..."
            )
            os.system("bash")
            exit()

        while (incorrect == True):
            password = open("Settings/kvnnadgz.bws", "r")
            passguess = input("Password # ")
            if (passguess == password.read()):
                incorrect = False
                systemvariables.init("usrsession", userguess)
            else:
                print("Incorrect Password.")
        password.close()
        print("Welcome to Bash(the Bourne Again Shell) for Windows!")

        while (True):
            # Load in prompt.bws variables
            os.chdir(systemvariables.read("settingspath") + "/Settings")

            # Store the contents of the prompt.bws file into memory
            file = open("prompt.bws", "r")
            promptConfigTxt = file.read()
            file.close()
            txtOnLine = [""]
            j = 0

            # Store each line of text in an array
            for i in promptConfigTxt:
                if (i == "\n"):
                    txtOnLine.append("")
                    j += 1
                    continue
                txtOnLine[j] = txtOnLine[j] + i
            # Seperate each value with equals sign and put them in a system variable, unless it has
            # a # as it's first character
            j = 0
            l = 0
            for i in txtOnLine:
                varNam = ""
                varConts = ""
                shift = 0
                l = 0
                for k in txtOnLine[j]:
                    if ((l == 0) and (k == "#")):
                        break
                    if (k == "="):
                        shift = 1
                        continue
                    if (shift == 0):
                        varNam = varNam + k
                    else:
                        varConts = varConts + k
                    l += 1
                if (varNam != ""):
                    systemvariables.init(varNam, varConts)
                j += 1

            # The varTrans variable's value should be converted into an integer, same for debugMsg and colorPrompt
            if ((systemvariables.read("varTrans") == "1")):
                systemvariables.modifyVoid("varTrans", 1)
            else:
                if (systemvariables.read("varTrans") != -1):
                    systemvariables.modifyVoid("varTrans", 0)
            if ((systemvariables.read("debugMsg") == "1")):
                systemvariables.modifyVoid("debugMsg", 1)
            else:
                if (systemvariables.read("debugMsg") != -1):
                    systemvariables.modifyVoid("debugMsg", 0)
            if ((systemvariables.read("colorPrompt") == "1")):
                systemvariables.modifyVoid("colorPrompt", 1)
            else:
                if (systemvariables.read("colorPrompt") != -1):
                    systemvariables.modifyVoid("colorPrompt", 0)

            # We need to go to the parent directory
            os.chdir("..")

            # Check for autorun.bws file, and call a function to take care of the rest
            if (os.path.exists("Settings/autorun.bws") == False):
                if (os.path.exists("Settings/noauto.bws") == False):
                    autorun = input(
                        "Bash for Windows cannot find a autorun.bws file. Create one? (Y,n) "
                    )
                    if ((autorun == "n") or (autorun == "N")):
                        touch.write(["Settings/noauto.bws"])
                    else:
                        touch.write(["Settings/autorun.bws"])
                        print(
                            "autorun.bws file has been placed inside of the Bash/Bash/Settings folder."
                        )
                        edit = input(
                            "Would you like to modify the autorun.bws file? (Y,n) "
                        )
                        if ((edit != "n") and (edit != "N")):
                            nano.write(["Settings/autorun.bws"])
                            file = open("Settings/autorun.bws", "r")
                            autoRun(str(file.read()))
                            file.close()
            else:
                file = open("Settings/autorun.bws", "r")
                autoRun(str(file.read()))
                file.close()

            user.close()
            if (bash.run() == 0):
                if (systemvariables.read("restart") == 1):
                    os.chdir(systemvariables.read("tmppath"))
                    file = open("lastcwd.bws", "r")
                    todir = file.read()
                    file.close()
                    systemvariables.modifyVoid("startDir", str(todir))
                    continue
            break
Beispiel #15
0
def run(qmake, profile_list):
    for i in profile_list:
        print('%s %s' % (qmake, i,))
        bash.run('%s %s' % (qmake, i,))
Beispiel #16
0
import sys
import multiprocessing

import bash

def run(qmake, profile_list):
    for i in profile_list:
        print('%s %s' % (qmake, i,))
        bash.run('%s %s' % (qmake, i,))

if __name__ == '__main__':
    if len(sys.argv) > 1:
        qmake = sys.argv[1]
    else:
        # Check if qmake is in path
        results = bash.run('which qmake')

        if results.return_code_success():
            qmake = results.stdout()
        else:
            print('no qmake in path. qmake must appear in path or full path passed as arg 1')
            sys.exit(1)

    # make number of processors qmake processes
    numProcs = int(bash.run('cat /proc/cpuinfo | grep processor | wc -l', False).stdout())

    # Divide up into lists for processing
    allProFiles = bash.run('find $(pwd) -name "*.pro" -type f').stdout().split('\n')

    lists = []
    for i in xrange(numProcs):