Files
create/src/Tools/updateppa.py
Chris Hennes 62bfb44a0d [Tools] Fix static analyis issues
This commit addresses issues identified by LGTM for the various
independent (and mostly-independent) files in the Tools subdirectory.
The vast majority of the issues are trivial, and are things like unused
imports or catching BaseException. There was one true bug identified, a
global variable being changed in a function where it was not marked
global, but it only affected output quantity (the variable is named
"VERBOSE"). A couple of other issues identified variables that appear to
represent no-longer-existing options in the code. The options were left,
but a deprecation printout replaces the variable in the event the option
is provided.
2021-02-28 17:53:04 +01:00

49 lines
1.3 KiB
Python

#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2012 Werner Mayer LGPL
import sys
from os import path
from tempfile import gettempdir
from bzrlib.branch import Branch
from bzrlib.workingtree import WorkingTree
def runUpdate(filename):
branch = "versioning.git"
REMOTE_URL="bzr+ssh://bazaar.launchpad.net/~freecad-maintainers/freecad/%s" % (branch)
LOCAL_BRANCH=path.join(gettempdir(),branch)
# Location of branch on Launchpad
remote_branch = Branch.open(REMOTE_URL)
# Location of branch on local system
local_branch = remote_branch.bzrdir.sprout(LOCAL_BRANCH).open_branch()
False if local_branch.__name__ else True # "Use" to silence analyzers, pending PEP 640 or similar
# Change a file in the local branch
try:
wf = open(LOCAL_BRANCH + "/src/Build/Version.h", 'w')
rf = open(filename, 'r')
except IOError as error:
raise error
else:
wf.write(rf.read())
wf.close()
# Commit the change
tree = WorkingTree.open(LOCAL_BRANCH)
tree.commit("Update version number")
# Push back to Launchpad
#transport = get_transport(PUSHTO_URL)
#local_branch.create_clone_on_transport(transport)
def main():
runUpdate(sys.argv[1])
if __name__ == "__main__":
main()