Example #1
0
def executeCommandOnProject(project_id, command, output_callback=None):
    """
    Execute a command on the workspace...
    :param project_id: ID of project to execute command on...
    :param output_callback: Lambda callback for output
    """
    cmd = SaveHelper.getProjectsDir(project_id) + "gradlew"
    if sys.platform != "win32":
        cmd = "bash " + cmd
    else:
        cmd = cmd.replace("/", "\\")
        cmd += ".bat"

    proc = subprocess.Popen(
        [cmd, command],
        cwd=SaveHelper.getProjectsDir(project_id),
        shell=False,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
    )
    if output_callback is not None:
        while True:
            line = proc.stdout.readline().decode("ascii")
            if not line:
                break
            line = line.replace("\r\n", "\n")
            line = line.replace("\n\n", "\n")
            if len(line) > 0:
                output_callback(line)
    proc.wait()
Example #2
0
 def delete(self):
     """
     Delete project from database and file system.
     """
     shutil.rmtree(SaveHelper.getProjectsDir(self.id))
     SaveHelper.executeNonQuery(
         "DELETE FROM projects WHERE ROWID = ?",
         self.id
     )
 def unzipForgeZip(self):
     """
     Unzip file into the project directory.
     """
     self.log_signal.emit("Unpacking working directory...", False)
     with ZipFile(SaveHelper.getDownloadsDir() + "MCF.zip") as z:
         z.extractall(SaveHelper.getProjectsDir(self.project_id))
         z.close()
     self.log_signal.emit("Done!", True)
     self.setupWorkspace()
 def cleanUpAfterInstall(self):
     """
     Clean up the downloaded files after the installation...
     """
     self.log_signal.emit("Cleaning up...", False)
     shutil.rmtree(SaveHelper.getDownloadsDir(), ignore_errors=False)
     self.log_signal.emit("Done!", False)
     self.main_btn_enable_signal.emit(True)
Example #5
0
 def update(self):
     """
     Update project details in database.
     """
     SaveHelper.executeNonQuery(
         """
         UPDATE projects
         SET name = ?,
             author = ?,
             version = ?
         WHERE ROWID = ?
         """,
         self.name,
         self.author,
         self.version,
         self.id
     )
 def startForgeDownload(self):
     """
     Download minecraft forge.
     """
     global FORGE_DOWNLOAD_URL
     self.log_signal.emit("Downloading minecraft forge...", False)
     NetworkHelper.downloadFile(FORGE_DOWNLOAD_URL, SaveHelper.getDownloadsDir() + "MCF.zip")
     self.log_signal.emit("Done!", True)
     self.unzipForgeZip()
Example #7
0
 def GetAllProjects():
     """
     Get all the saved projects in our database.
     :return: Project[]
     """
     projects = []
     response = SaveHelper.executeQuery("SELECT ROWID, * FROM projects ORDER BY timestamp DESC")
     for row in response:
         projects.append(Project.FromRow(row))
     return projects
Example #8
0
 def FromCommand(command):
     """
     Load a command with details from the database.
     :param command: command that is being called (string)
     :return:
     """
     response = SaveHelper.executeQuery("SELECT * FROM workspace_commands WHERE command_value = ?", command)
     if len(response) == 0:
         return None
     else:
         return Command.FromRow(response[0])
 def beginProjectInstallation(self):
     """
     Begin installation of this project.
     """
     self.main_btn_enable_signal.emit(False)
     SaveHelper.executeNonQuery(
         """
         INSERT INTO projects(
             name,
             author,
             version
         ) VALUES (?, ?, ?)
         """,
         self.project_name,
         self.project_author,
         self.project_version,
     )
     id = SaveHelper.getLastInsertId()
     self.project_id = id
     path = SaveHelper.getProjectsDir(self.project_id)
     if not os.path.exists(path):
         os.makedirs(path)
     if not os.path.exists(SaveHelper.getDownloadsDir()):
         os.makedirs(SaveHelper.getDownloadsDir())
     self.worker_thread.start()