Beispiel #1
0
 def initialcommitandpush():
     shouter.shout("Initial git add")
     shell.execute("git add -A", os.devnull)
     shouter.shout("Finished initial git add, starting commit")
     shell.execute("git commit -m %s -q" % shell.quote("Initial Commit"))
     shouter.shout("Finished commit")
     shell.execute("git push origin master")
     shouter.shout("Finished push")
Beispiel #2
0
 def createattributes():
     """
     create a .gitattributes file (if so specified and not yet present)
     """
     config = configuration.get()
     if len(config.gitattributes) > 0:
         gitattribues = ".gitattributes"
         if not os.path.exists(gitattribues):
             with open(gitattribues, "w") as attributes:
                 for line in config.gitattributes:
                     attributes.write(line + '\n')
             shell.execute("git add " + gitattribues)
             shell.execute("git commit -m %s -q" %
                           shell.quote("Add .gitattributes"))
Beispiel #3
0
 def createattributes():
     """
     create a .gitattributes file (if so specified and not yet present)
     """
     config = configuration.get()
     if len(config.gitattributes) > 0:
         newline = os.linesep
         gitattribues = ".gitattributes"
         if not os.path.exists(gitattribues):
             with open(gitattribues, "w") as attributes:
                 for line in config.gitattributes:
                     attributes.write(line + newline)
             shell.execute("git add " + gitattribues)
             shell.execute("git commit -m %s -q" % shell.quote("Add .gitattributes"))
Beispiel #4
0
    def createignore():
        newline = os.linesep
        git_ignore = ".gitignore"

        if not os.path.exists(git_ignore):
            with open(git_ignore, "w") as ignore:
                ignore.write(".jazz5" + newline)
                ignore.write(".metadata" + newline)
                ignore.write(".jazzShed" + newline)
                config = configuration.get()
                if len(config.ignoredirectories) > 0:
                    ignore.write(newline + "# directories" + newline)
                    for directory in config.ignoredirectories:
                        ignore.write('/' + directory + newline)
                    ignore.write(newline)
            shell.execute("git add " + git_ignore)
            shell.execute("git commit -m %s -q" % shell.quote("Add .gitignore"))
Beispiel #5
0
    def createignore():
        git_ignore = ".gitignore"

        if not os.path.exists(git_ignore):
            with open(git_ignore, "w") as ignore:
                ignore.write(".jazz5" + '\n')
                ignore.write(".metadata" + '\n')
                ignore.write(".jazzShed" + '\n')
                config = configuration.get()
                if len(config.ignoredirectories) > 0:
                    ignore.write('\n' + "# directories" + '\n')
                    for directory in config.ignoredirectories:
                        ignore.write('/' + directory + '\n')
                    ignore.write('\n')
            shell.execute("git add " + git_ignore)
            shell.execute("git commit -m %s -q" %
                          shell.quote("Add .gitignore"))
Beispiel #6
0
 def replaceauthor(author, email):
     shell.execute("git config --replace-all user.name " + shell.quote(author))
     shell.execute("git config --replace-all user.email " + email)
Beispiel #7
0
 def getcommitcommand(changeentry):
     comment = Commiter.getcommentwithprefix(changeentry.comment)
     return "git commit -m %s --date %s --author=%s" \
            % (shell.quote(comment), shell.quote(changeentry.date), changeentry.getgitauthor())
Beispiel #8
0
 def replaceauthor(author, email):
     shell.execute("git config --replace-all user.name " + shell.quote(author))
     shell.execute("git config --replace-all user.email " + email)
Beispiel #9
0
 def getcommitcommand(changeentry):
     comment = Commiter.replacegitcreatingfilesymbol(changeentry.comment)
     return "git commit -m %s --date %s --author=%s" \
            % (shell.quote(comment), shell.quote(changeentry.date), changeentry.getgitauthor())
Beispiel #10
0
def main(args):
    if args["help"]:
        print __doc__.rstrip()
        return None

    do_log = not args["run"] or args["--verbose"]
    if do_log:
        if args["--verbose"]:
            shell.COMMAND_DEFAULTS["mvn"] = "mvn"
        logging.basicConfig(level=logging.DEBUG)
        log = logging.getLogger("quark")
        log.propagate = False
        hnd = ProgressHandler(verbose=args["--verbose"])
        log.addHandler(hnd)
        hnd.setFormatter(logging.Formatter("%(message)s"))

    version = "Quark %s run at %s" % (_metadata.__version__, datetime.datetime.now())
    helpers.Code.identifier = version

    java = args["--java"]
    ruby = args["--ruby"]
    python = args["--python"]
    python3 = args["--python3"]
    javascript = args["--javascript"]

    all = args["--all"] or not (java or python or javascript or ruby or python3)

    output = args["--output"]
    offline = not args["--online"]

    try:
        shell.command_log.info("Checking environment")
        backends = []
        if java or all:
            if args["install"]: shell.check("mvn")
            backends.append(backend.Java)
        if ruby or all:
            if args["install"]: shell.check("gem")
            backends.append(backend.Ruby)
        if python or all:
            if args["install"]:
                shell.check("python2")
                shell.check("pip2")
            backends.append(backend.Python)
        if python3 or all:
            if args["install"]:
                shell.check("python3")
                shell.check("pip3")
            backends.append(backend.Python3)
        if javascript or all:
            if args["install"]: shell.check("npm")
            backends.append(backend.JavaScript)

        filenames = args["<file>"] or [compiler.join(None, compiler.BUILTIN_FILE)]
        for url in filenames:
            c = compiler.Compiler(args["--include-stdlib"])
            c.version_warning = args["--version-warning"]
            if args["install"]:
                compiler.install(c, url, offline, *backends)
            elif args["compile"]:
                compiler.compile(c, url, output, *backends)
            elif args["run"]:
                compiler.run(c, url, args["<args>"], *backends)
            elif args["docs"]:
                compiler.make_docs(c, url, output, args["--include-private"])
            else:
                assert False
    except (KeyboardInterrupt, QuarkError) as err:
        if not args["run"]:
            shell.command_log.error("")
        if args["install"] and offline and isinstance(err, shell.ShellError):
            err = str(err) + "\n\n"
            err += "Please retry the command with the --online switch\n\n"
            err += "    quark install --online "
            for opt in "--verbose --java --javascript --ruby --python --python3".split():
                if args[opt]: err += opt + " "
            err += " ".join(shell.quote(f) for f in args["<file>"])
            err += "\n"
        return err
    except:  # pylint: disable=bare-except
        if do_log:
            import inspect
            ast_stack = helpers.format_ast_stack(inspect.trace())
            shell.command_log.error("\n -- snip --\nInternal compiler error, %s\n\n" %  version, exc_info=True)
            if ast_stack:
                shell.command_log.error("\nCompiler was looking at:\n%s\n" % ast_stack)
        instructions = textwrap.dedent("""\

        Your code triggered an internal compiler error.

        Please report the issue at https://github.com/datawire/quark/issues
        """)
        if do_log:
            instructions += textwrap.dedent("""\

            Please attach the above report up until the -- snip -- line with the issue.
            If at all possible also attach the quark file that caused the error.
            """)
        else:
            instructions += textwrap.dedent("""\

            Please re-run the quark command with --verbose flag to get the full report.
            """)
        return instructions

    shell.command_log.warn("Done")
Beispiel #11
0
 def replaceauthor(author, email):
     shell.execute("git config --replace-all user.name " +
                   shell.quote(author))
     if not email:
         email = Commiter.defaultemail(author)
     shell.execute("git config --replace-all user.email " + email)
Beispiel #12
0
 def getcommitcommand(changeentry):
     comment = Commiter.getcommentwithprefix(changeentry.comment)
     return "git commit -m %s --date %s --author=%s" \
            % (shell.quote(comment), shell.quote(changeentry.date), changeentry.getgitauthor())
Beispiel #13
0
 def getgitauthor(self):
     authorrepresentation = "%s <%s>" % (self.author, self.email)
     return shell.quote(authorrepresentation)
Beispiel #14
0
def main(args):
    if args["help"]:
        print __doc__.rstrip()
        return None

    do_log = not args["run"] or args["--verbose"]
    if do_log:
        if args["--verbose"]:
            shell.COMMAND_DEFAULTS["mvn"] = "mvn"
        logging.basicConfig(level=logging.DEBUG)
        log = logging.getLogger("quark")
        log.propagate = False
        hnd = ProgressHandler(verbose=args["--verbose"])
        log.addHandler(hnd)
        hnd.setFormatter(logging.Formatter("%(message)s"))

    version = "Quark %s run at %s" % (_metadata.__version__,
                                      datetime.datetime.now())
    helpers.Code.identifier = version

    java = args["--java"]
    ruby = args["--ruby"]
    python = args["--python"]
    python3 = args["--python3"]
    javascript = args["--javascript"]

    all = args["--all"] or not (java or python or javascript or ruby
                                or python3)

    output = args["--output"]
    offline = not args["--online"]

    try:
        shell.command_log.info("Checking environment")
        backends = []
        if java or all:
            if args["install"]: shell.check("mvn")
            backends.append(backend.Java)
        if ruby or all:
            if args["install"]: shell.check("gem")
            backends.append(backend.Ruby)
        if python or all:
            if args["install"]:
                shell.check("python2")
                shell.check("pip2")
            backends.append(backend.Python)
        if python3 or all:
            if args["install"]:
                shell.check("python3")
                shell.check("pip3")
            backends.append(backend.Python3)
        if javascript or all:
            if args["install"]: shell.check("npm")
            backends.append(backend.JavaScript)

        filenames = args["<file>"] or [
            compiler.join(None, compiler.BUILTIN_FILE)
        ]
        for url in filenames:
            c = compiler.Compiler(args["--include-stdlib"])
            c.version_warning = args["--version-warning"]
            if args["install"]:
                compiler.install(c, url, offline, *backends)
            elif args["compile"]:
                compiler.compile(c, url, output, *backends)
            elif args["run"]:
                compiler.run(c, url, args["<args>"], *backends)
            elif args["docs"]:
                compiler.make_docs(c, url, output, args["--include-private"])
            else:
                assert False
    except (KeyboardInterrupt, QuarkError) as err:
        if not args["run"]:
            shell.command_log.error("")
        if args["install"] and offline and isinstance(err, shell.ShellError):
            err = str(err) + "\n\n"
            err += "Please retry the command with the --online switch\n\n"
            err += "    quark install --online "
            for opt in "--verbose --java --javascript --ruby --python --python3".split(
            ):
                if args[opt]: err += opt + " "
            err += " ".join(shell.quote(f) for f in args["<file>"])
            err += "\n"
        return err
    except:  # pylint: disable=bare-except
        if do_log:
            import inspect
            ast_stack = helpers.format_ast_stack(inspect.trace())
            shell.command_log.error(
                "\n -- snip --\nInternal compiler error, %s\n\n" % version,
                exc_info=True)
            if ast_stack:
                shell.command_log.error("\nCompiler was looking at:\n%s\n" %
                                        ast_stack)
        instructions = textwrap.dedent("""\

        Your code triggered an internal compiler error.

        Please report the issue at https://github.com/datawire/quark/issues
        """)
        if do_log:
            instructions += textwrap.dedent("""\

            Please attach the above report up until the -- snip -- line with the issue.
            If at all possible also attach the quark file that caused the error.
            """)
        else:
            instructions += textwrap.dedent("""\

            Please re-run the quark command with --verbose flag to get the full report.
            """)
        return instructions

    shell.command_log.warn("Done")
Beispiel #15
0
 def initialcommit():
     shouter.shout("Initial git add")
     shell.execute("git add -A", os.devnull)
     shouter.shout("Finished initial git add, starting commit")
     shell.execute("git commit -m %s -q" % shell.quote("Initial Commit"))
     shouter.shout("Finished initial commit")
Beispiel #16
0
 def initialcommit():
     shouter.shout("Initial git add")
     shell.execute("git add -A", os.devnull)
     shouter.shout("Finished initial git add, starting commit")
     shell.execute("git commit -m %s -q" % shell.quote("Initial Commit"))
     shouter.shout("Finished initial commit")
Beispiel #17
0
 def getgitauthor(self):
     authorrepresentation = "%s <%s>" % (self.author, self.email)
     return shell.quote(authorrepresentation)