]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Python/WorkspaceRoutines.py
3 # Copyright (c) 2007, Intel Corporation
4 # All rights reserved. This program and the accompanying materials
5 # are licensed and made available under the terms and conditions of the BSD License
6 # which accompanies this distribution. The full text of the license may be found at
7 # http://opensource.org/licenses/bsd-license.php
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 import os
, sys
, re
, getopt
, string
, glob
, xml
.dom
.minidom
, pprint
, md5
, socket
, getpass
, time
, random
14 def inWorkspace(rel_path
=""):
15 """Treat the given path as relative to the workspace."""
17 # Make sure the user has set the workspace variable:
19 return os
.path
.join(os
.environ
["WORKSPACE"], rel_path
)
21 print "Oops! You must set the WORKSPACE environment variable to run this script."
26 str(random
.random()) +
29 socket
.gethostbyname(socket
.gethostname())).hexdigest()
30 return Guid("%s-%s-%s-%s-%s" % (g
[0:8], g
[8:12], g
[12:16], g
[16:20], g
[20:]))
33 """Lean the slashes forward"""
35 return os
.path
.normpath(path
).replace("\\", "/")
38 """Make a directory if it is not there already."""
50 f
=open(filename
, "rb")
51 sum = md5
.md5(f
.read()).hexdigest()
54 print "Error: Unable to open file: %s" % filename
60 """Convert the guid string into a canonical form suitable for comparison."""
61 return string
.lower(guidString
)