示例#1
0
 def easy_install(self, log):
     release.clean_dir(self._env, self._install_dir)
     check_not_installed(self._install_dir_on_pythonpath, self._python)
     output = release.get_cmd_stdout(
         self._install_dir_on_pythonpath, self._easy_install_cmd +
         ["-d", self._install_dir, self._project_name])
     # easy_install doesn't fail properly :-(
     if "SyntaxError" in output:
         raise Exception(output)
     check_version_equals(self._install_dir_on_pythonpath,
                          self._expected_version, self._python)
示例#2
0
 def easy_install(self, log):
     clean_dir(self._env, self._install_dir)
     self._check_not_installed()
     output = release.get_cmd_stdout(
         self._install_dir_on_pythonpath,
         self._easy_install_cmd + ["-d", self._install_dir,
                                   self._project_name])
     # easy_install doesn't fail properly :-(
     if "SyntaxError" in output:
         raise Exception(output)
     self._check_version_equals(self._expected_version)
示例#3
0
 def _get_next_release_version(self):
     # --pretend / git not installed
     most_recent, next = "dummy version", "dummy version"
     try:
         tags = release.get_cmd_stdout(self._in_source_repo,
                                       ["git", "tag", "-l"]).split()
     except cmd_env.CommandFailedError:
         pass
     else:
         versions = [release.parse_version(tag) for tag in tags]
         if versions:
             most_recent = max(versions)
             next = most_recent.next_version()
     return most_recent, next
示例#4
0
 def _get_next_release_version(self):
     # --pretend / git not installed
     most_recent, next = "dummy version", "dummy version"
     try:
         tags = release.get_cmd_stdout(self._in_source_repo,
                                       ["git", "tag", "-l"]).split()
     except cmd_env.CommandFailedError:
         pass
     else:
         versions = [release.parse_version(tag) for tag in tags]
         if versions:
             most_recent = max(versions)
             next = most_recent.next_version()
     return most_recent, next
示例#5
0
def check_version_equals(env, version, python):
    try:
        output = release.get_cmd_stdout(
            env,
            [python, "-c", "import mechanize; print mechanize.__version__"],
            stderr=subprocess.PIPE)
    except cmd_env.CommandFailedError:
        raise WrongVersionError(None)
    else:
        version_tuple_string = output.strip()
        assert len(version.tuple) == 6, len(version.tuple)
        if not (version_tuple_string == str(version.tuple)
                or version_tuple_string == str(version.tuple[:-1])):
            raise WrongVersionError(version_tuple_string)
示例#6
0
def check_version_equals(env, version, python):
    try:
        output = release.get_cmd_stdout(
            env,
            [python, "-c",
             "import mechanize; print mechanize.__version__"],
            stderr=subprocess.PIPE)
    except cmd_env.CommandFailedError:
        raise WrongVersionError(None)
    else:
        version_tuple_string = output.strip()
        assert len(version.tuple) == 6, len(version.tuple)
        if not(version_tuple_string == str(version.tuple) or
               version_tuple_string == str(version.tuple[:-1])):
            raise WrongVersionError(version_tuple_string)
示例#7
0
 def _get_next_tag_from_repo(self):
     # Dry run or no tags
     next_ = "dummy"
     try:
         tag_lines = release.get_cmd_stdout(
             self._env, ["git", "show-ref", "--tags"])
         tags = []
         for line in tag_lines.splitlines():
             tag = line.split()[1].split("refs/tags/")[1]
             tags.append(tag)
     except cmd_env.CommandFailedError:
         pass
     else:
         versions = [release.parse_version(t) for t in tags]
         if len(versions) != 0:
             most_recent = max(versions)
             next_ = str(most_recent.next_version())
         return next_
示例#8
0
 def _get_next_tag_from_repo(self):
     # Dry run or no tags
     next_ = "dummy"
     try:
         tag_lines = release.get_cmd_stdout(self._env,
                                            ["git", "show-ref", "--tags"])
         tags = []
         for line in tag_lines.splitlines():
             tag = line.split()[1].split("refs/tags/")[1]
             tags.append(tag)
     except cmd_env.CommandFailedError:
         pass
     else:
         versions = [release.parse_version(t) for t in tags]
         if len(versions) != 0:
             most_recent = max(versions)
             next_ = str(most_recent.next_version())
         return next_
示例#9
0
    def validate_css(self, log):
        env = cmd_env.PrefixCmdEnv(self._classpath_cmd(), self._in_release_dir)
        # env.cmd(["java", "org.w3c.css.css.CssValidator", "--help"])
        """
Usage: java org.w3c.css.css.CssValidator  [OPTIONS] | [URL]*
OPTIONS
	-p, --printCSS
		Prints the validated CSS (only with text output, the CSS is printed with other outputs)
	-profile PROFILE, --profile=PROFILE
		Checks the Stylesheet against PROFILE
		Possible values for PROFILE are css1, css2, css21 (default), css3, svg, svgbasic, svgtiny, atsc-tv, mobile, tv
	-medium MEDIUM, --medium=MEDIUM
		Checks the Stylesheet using the medium MEDIUM
		Possible values for MEDIUM are all (default), aural, braille, embossed, handheld, print, projection, screen, tty, tv, presentation
	-output OUTPUT, --output=OUTPUT
		Prints the result in the selected format
		Possible values for OUTPUT are text (default), xhtml, html (same result as xhtml), soap12
	-lang LANG, --lang=LANG
		Prints the result in the specified language
		Possible values for LANG are de, en (default), es, fr, ja, ko, nl, zh-cn, pl, it
	-warning WARN, --warning=WARN
		Warnings verbosity level
		Possible values for WARN are -1 (no warning), 0, 1, 2 (default, all the warnings

URL
	URL can either represent a distant web resource (http://) or a local file (file:/)
"""
        validate_cmd = ["java", "org.w3c.css.css.CssValidator"]
        for dirpath, dirnames, filenames in os.walk(self._mirror_path):
            for filename in filenames:
                if filename.endswith(".css"):
                    path = os.path.join(dirpath, filename)
                    temp_path, tear_down = self._sanitise_css(path)
                    try:
                        page_url = "file://" + temp_path
                        output = release.get_cmd_stdout(
                            env, validate_cmd + [page_url])
                    finally:
                        tear_down()
                    # the validator doesn't fail properly: it exits
                    # successfully on validation failure
                    if "Sorry! We found the following errors" in output:
                        raise CSSValidationError(path, output)
示例#10
0
    def validate_css(self, log):
        env = cmd_env.PrefixCmdEnv(self._classpath_cmd(), self._in_release_dir)
        # env.cmd(["java", "org.w3c.css.css.CssValidator", "--help"])
        """
Usage: java org.w3c.css.css.CssValidator  [OPTIONS] | [URL]*
OPTIONS
	-p, --printCSS
		Prints the validated CSS (only with text output, the CSS is printed with other outputs)
	-profile PROFILE, --profile=PROFILE
		Checks the Stylesheet against PROFILE
		Possible values for PROFILE are css1, css2, css21 (default), css3, svg, svgbasic, svgtiny, atsc-tv, mobile, tv
	-medium MEDIUM, --medium=MEDIUM
		Checks the Stylesheet using the medium MEDIUM
		Possible values for MEDIUM are all (default), aural, braille, embossed, handheld, print, projection, screen, tty, tv, presentation
	-output OUTPUT, --output=OUTPUT
		Prints the result in the selected format
		Possible values for OUTPUT are text (default), xhtml, html (same result as xhtml), soap12
	-lang LANG, --lang=LANG
		Prints the result in the specified language
		Possible values for LANG are de, en (default), es, fr, ja, ko, nl, zh-cn, pl, it
	-warning WARN, --warning=WARN
		Warnings verbosity level
		Possible values for WARN are -1 (no warning), 0, 1, 2 (default, all the warnings

URL
	URL can either represent a distant web resource (http://) or a local file (file:/)
"""
        validate_cmd = ["java", "org.w3c.css.css.CssValidator"]
        for dirpath, dirnames, filenames in os.walk(self._mirror_path):
            for filename in filenames:
                if filename.endswith(".css"):
                    path = os.path.join(dirpath, filename)
                    temp_path, tear_down = self._sanitise_css(path)
                    try:
                        page_url = "file://" + temp_path
                        output = release.get_cmd_stdout(
                            env, validate_cmd + [page_url])
                    finally:
                        tear_down()
                    # the validator doesn't fail properly: it exits
                    # successfully on validation failure
                    if "Sorry! We found the following errors" in output:
                        raise CSSValidationError(path, output)
示例#11
0
    def write_email(self, log):
        log = release.get_cmd_stdout(self._in_repo,
                                     ["git", "log", '--pretty=format: * %s',
                                      "%s..HEAD" % self._previous_version])
        # filter out some uninteresting commits
        log = "".join(line for line in log.splitlines(True) if not
                      re.match("^ \* Update (?:changelog|version)$", line,
                               re.I))
        self._in_release_dir.cmd(cmd_env.write_file_cmd(
                "announce_email.txt", u"""\
ANN: mechanize {version} released

http://wwwsearch.sourceforge.net/mechanize/

This is a stable bugfix release.

Changes since {previous_version}:

{log}

About mechanize
=============================================

Requires Python 2.4, 2.5, 2.6, or 2.7.


Stateful programmatic web browsing, after Andy Lester's Perl module
WWW::Mechanize.

Example:

import re
from mechanize import Browser

b = Browser()
b.open("http://www.example.com/")
# follow second link with element text matching regular expression
response = b.follow_link(text_regex=re.compile(r"cheese\s*shop"), nr=1)

b.select_form(name="order")
# Browser passes through unknown attributes (including methods)
# to the selected HTMLForm
b["cheeses"] = ["mozzarella", "caerphilly"]  # (the method here is __setitem__)
response2 = b.submit()  # submit current form

response3 = b.back()  # back to cheese shop
response4 = b.reload()

for link in b.forms():
       print form
# .links() optionally accepts the keyword args of .follow_/.find_link()
for link in b.links(url_regex=re.compile("python.org")):
       print link
       b.follow_link(link)  # can be EITHER Link instance OR keyword args
       b.back()


John
""".format(log=log,
           version=self._release_version,
           previous_version=self._previous_version)))
示例#12
0
    def write_email(self, log):
        log = release.get_cmd_stdout(self._in_repo,
                                     ["git", "log", '--pretty=format: * %s',
                                      "%s..HEAD" % self._previous_version])
        # filter out some uninteresting commits
        log = "".join(line for line in log.splitlines(True) if not
                      re.match("^ \* Update (?:changelog|version)$", line,
                               re.I))
        self._in_release_dir.cmd(cmd_env.write_file_cmd(
                "announce_email.txt", u"""\
ANN: mechanize {version} released

http://wwwsearch.sourceforge.net/mechanize/

This is a stable bugfix release.

Changes since {previous_version}:

{log}

About mechanize
=============================================

Requires Python 2.4, 2.5, 2.6, or 2.7.


Stateful programmatic web browsing, after Andy Lester's Perl module
WWW::Mechanize.

Example:

import re
from mechanize import Browser

b = Browser()
b.open("http://www.example.com/")
# follow second link with element text matching regular expression
response = b.follow_link(text_regex=re.compile(r"cheese\s*shop"), nr=1)

b.select_form(name="order")
# Browser passes through unknown attributes (including methods)
# to the selected HTMLForm
b["cheeses"] = ["mozzarella", "caerphilly"]  # (the method here is __setitem__)
response2 = b.submit()  # submit current form

response3 = b.back()  # back to cheese shop
response4 = b.reload()

for link in b.forms():
       print form
# .links() optionally accepts the keyword args of .follow_/.find_link()
for link in b.links(url_regex=re.compile("python.org")):
       print link
       b.follow_link(link)  # can be EITHER Link instance OR keyword args
       b.back()


John
""".format(log=log,
           version=self._release_version,
           previous_version=self._previous_version)))
 def _get_version_from_changelog(self):
     output = release.get_cmd_stdout(
         self._in_repo, ["dpkg-parsechangelog", "--format", "rfc822"])
     message = rfc822.Message(StringIO.StringIO(output))
     [version] = message.getheaders("Version")
     return version