Exemple #1
0
    def pull(self, chat_id, args=None):
        # Define Branch! When None, Default pull!
        if self._filepath == '':
            print("Cannot pull without Filepath!")
            self._bot.sendMessage(
                chat_id, "No Filepath for Git found! Check the Logs!")
            return
        if self._bot is None:
            raise ReferenceError("Cannot use Function without Bot Context!")

        if len(args) > 1:
            branch = args[1]
            _logger.info("Checkout new Branch %s from Git", branch)
            out, err = helper.execute("cd " + self._filepath +
                                      " && git checkout " + branch +
                                      " && git pull")
        else:
            _logger.info("Pulling updates from Git")
            out, err = helper.execute("cd " + self._filepath + " && git pull")

        if len(err) > 0:
            result = err + "\n\n" + out
        else:
            result = out
        self._bot.sendMessage(chat_id,
                              result +
                              "\nTask finished! Do you want to restart now?",
                              reply_markup=helper.restart_keyboard)
Exemple #2
0
 def fetch(self, chat_id, args=None):
     out, err = helper.execute("cd " + self._filepath + " && git fetch")
     if len(err) > 0:
         result = err + "\n\n" + out
     else:
         result = out
     self._bot.sendMessage(chat_id, result + "\nTask finished!")
    def handle(self, input):
        firstLine, code = input.split("\n",1)
        command, fakeargs = firstLine.split(" ", 1)

        executed, err =helper.execute([command,'-c',"""\n{0}""".format(code)])

        self.result = "\n".join([firstLine, executed]).rstrip("\n")
Exemple #4
0
    def is_enabled(self):
        if not path.isdir(self._filepath + '/.git'):
            return False

        _, err = helper.execute('git --version')

        return len(err) == 0
Exemple #5
0
def deleteHistory():
    filesDeleted = deleteAllFiles(chromeDataStr)
    log("Deleted " + str(filesDeleted) + " Chrome files.")
    numFolderDeleted = execute(
        r'FOR /D %p IN ("' + chromeDataStr +
        r'\*.*") DO (if not "%~np"=="Default" rmdir "%p" /s /q)', r'rmdir') - 1
    log("Removed " + str(numFolderDeleted) + " Chrome storage folders.")
    return [filesDeleted, numFolderDeleted]
Exemple #6
0
 def get_current_branch(self):
     _logger.info("Getting Current Git Branch")
     out, err = helper.execute("cd " + self._filepath +
                               " && git symbolic-ref HEAD")
     if len(err) > 0:
         return "No Git!"
     l = out.split('/')
     return '/'.join(l[2:]).strip()
    def handle(self, input):
        result = self.pattern.match(input)

        command = result.group(1)
        args = result.group(2)

        execution_result, err =helper.execute("{0} {1}".format(command, args).split(" "))

        self.result = "$ " + command + " " + args + "\n" + execution_result
def deleteAllDesktopShortcuts():
    output = execute(
        'for /R ' + desktopStr +
        ' %f in (*) do (if not "%~xf"==".lnk" del "%~f")', '', True)
    tests = re.findall(r'== "\.lnk"', output)
    nonDeletions = re.findall(r'"\.lnk" == "\.lnk"', output)
    log("Deleted " + str(len(tests) - len(nonDeletions)) +
        " files from the Desktop.")
    return len(tests) - len(nonDeletions)
    def handle(self, input):
        m = self.pattern.match(input)
        fpath, fname,  ext = m.group(1), m.group(2), m.group(3)
        originalFile = path.join(fpath, fname + ext)

        if not path.exists(originalFile):
            self.result = "" #"\\include{"+ originalFile +"}"
            logging.warn("'{0}' is not a file!".format(originalFile))
            logging.warn("It will not be included in the resulting .tex file.")
            return

        #if ext not "xtex": warn("Extension not xtex in {0}".format(fpath+ext))
        if not path.exists(include_folder):
            makedirs(include_folder)

        targetPath = path.join(include_folder, fpath, fname)
        result, err= helper.execute(["python",thisScript, originalFile, targetPath+".tex"])

        # if err: out err
        # newPath = path.join(include_folder, path)
        self.result = "\\include{"+ targetPath +"}"
Exemple #10
0
def closeChrome():
    log("Attempting to close Chrome.")
    instancesKilled = execute('taskkill /f /im chrome.exe', r'terminated')
    log("Killed " + str(instancesKilled) + " running instances of Chrome.")
    return instancesKilled
def deleteAllFolders(directory):
    return execute(
        'FOR /D %p IN ("' + directory + r'\*.*") DO rmdir "%p" /s /q',
        r'rmdir')
def deleteAllFiles(directory):
    return execute('del /S /Q "' + directory + '"', r'Deleted file')