schrodinger.test.stu.common module¶
Functions that are used in one or more modules. reduces danger of circular dependencies.
@copyright: Schrodinger, Inc. All rights reserved.
-
schrodinger.test.stu.common.
BASE_URL
= 'https://stu.schrodinger.com'¶ Address of STU server
-
schrodinger.test.stu.common.
DATE_RE
= '^\\d\\d\\d\\d-\\d\\d-\\d\\d$'¶ The date format that our NBs use.
-
schrodinger.test.stu.common.
BUILD_ID_RE
= re.compile('build(?:\\d{2}\\b|-\\d{3}\\b)')¶ Updated build_id naming scheme.
-
exception
schrodinger.test.stu.common.
ZipError
[source]¶ Bases:
Exception
Error while zipping up files.
-
__init__
(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
schrodinger.test.stu.common.
str2list
(string)[source]¶ Takes a string which can be a comma- or space-separated collection of positive integers and ranges and returns an ordered list of numbers.
- Parameters
input_string (str) – A comma-separated string of positive integers and ranges
- Returns
An ordered list of integers
- Return type
list(int)
-
schrodinger.test.stu.common.
str2strlist
(string)[source]¶ Split a string into a list of strings. Used in parser.
-
schrodinger.test.stu.common.
get_api_key
()[source]¶ Get the user’s API key. Uses caching. Also ensures that the user’s API key is only readable by self - raises RuntimeError if anyone else has read permission.
- Return type
str
- Returns
User’s API key from disk.
-
schrodinger.test.stu.common.
assert_build_id_matches
(buildtype, build_id)[source]¶ Check that the build_id is appropriate for the buildtype
-
schrodinger.test.stu.common.
verify_zip
(fileobj)[source]¶ Attempt to open fileobj as a zipfile.ZipFile and check it for errors using ZipFile.testzip() (file headers and CRC32 check for all files).
- Raises
ZipError – If ZipFile.testzip() retuns a non-None value, indicating a corrupted file.
-
schrodinger.test.stu.common.
zip_files
(fileobj, relative_to, filenames)[source]¶ Zip a list of files into an archive. Relative paths are relative to
relative_to
.
-
schrodinger.test.stu.common.
zip_directory
(dirname, fileobj=None, skipped_files=None)[source]¶ Zip the contents of a directory. File names will be relative to the directory name. Preserves symlinks :type dirname: str :param dirname: Directory to be zipped
- Parameters
fileobj (file-like object or path to file) – Directory will be zipped to this filename or into this file-like object.
skipped_files (set) – Names of files that should be excluded from the zip archive.