schrodinger.application.licensing.flexlm module¶
- exception schrodinger.application.licensing.flexlm.IncompatibleLicenseError¶
Bases:
Exception
This exception is thrown from the merge operations when incompatibilities between the old and new license prevent make merging them impossible.
- exception schrodinger.application.licensing.flexlm.LicfileError¶
Bases:
Exception
This exception is thrown by the main code if asked to work with something that isn’t an actual license file. It’s also thrown by the license-file parsing code when an unparseable line is encountered.
- schrodinger.application.licensing.flexlm.set_logger(new_log)¶
Allow a client to specify our logger.
- schrodinger.application.licensing.flexlm.set_file_logger(new_file_log)¶
Allow a client to specify our file logger.
- schrodinger.application.licensing.flexlm.parse_line(license_line, line_num=0)¶
Parse a complete FLEXlm license line into it’s component parts.
Duplicate lines are rejected at this stage. (To detect duplicates, we just consider the digital signature fields.)
This method returns an object representing the contents of that line, This will be a Feature, Package, Server, Vendor or UseServer object.
- schrodinger.application.licensing.flexlm.parse_date(date_text)¶
Parse a FLEXlm date string, which is in the format “dd-mmm-yyyy”.
A date object is returned.
- schrodinger.application.licensing.flexlm.parse_expiration(exp_text)¶
Parse the expiration field of a FEATURE/INCREMENT line. This can either be a standard dd-mm-yyyy date, “0”, or “permanent”. An expiration of “0” indicates a permanent license.
A date object is returned. For a permanent license, the value returned is the maximum representable date.
- schrodinger.application.licensing.flexlm.parse_tokens(count_text)¶
Parse the token-count field of a FEATURE/INCREMENT line. This can either be a positive interger, to indicate the number of tokens, “0”, or “uncounted”. A count of “0” indicates an uncounted licese.
An integer is returned. For an uncounted license, 0 is returned.
- schrodinger.application.licensing.flexlm.parse_components(components_text)¶
Parse the COMPONENTS field of a PACKAGE line. This is a list of features, with an optional version number and token count for each feature.
A list of (feature_name, version, count) tuples is returned.
- schrodinger.application.licensing.flexlm.matches_canonical_filename(filename)¶
Does the filename match the canonical pattern?
<2 digit priority>_<license class>_<date issued>_<optional descriptor>.lic
- schrodinger.application.licensing.flexlm.hostid_order(hostid)¶
Return a index that can be used to order license lines with the given hostid relative to other similar lines with different hostids. This is used to construct the standard sort key.
Typical hostid types used in Schrodinger license are 1. ethernet address 2. IP range 3. ANY 4. none
We would like more restricted licenses to be listed first in the license file.
- class schrodinger.application.licensing.flexlm.License(text: Optional[str] = '', filename: Optional[str] = None)¶
Bases:
object
A License object represents a single FLEXlm license file.
It is composed of objects representing the components of the file, including:
One or three SERVER lines [optional]
A VENDOR line [optional]
A USE_SERVER line [optional]
Any number of FEATURE, INCREMENT, and PACKAGE lines. [reqd]
License objects are initialized by reading a license file. The contents of that file kept as a list of Server, Vendor, Feature and Package objects, each representing a single line in the license file.
- __init__(text: Optional[str] = '', filename: Optional[str] = None)¶
- Parameters
text – License content as string. This is used only for testing.
filename – License content to read from the given file. This is the preferred way to initialize the License instance in production.
- write(outfile, dryrun=False, backup=True)¶
Write the license file to a file named ‘outfile’
- log_deleted_lines(newlic)¶
Report in the logfile any lines that exist in this license, but not in newlic.
- canonical_filename()¶
Return the filename for this license file, according to the our conventions for naming licenses in license directories. License filenames should have the following form:
<index>_<classname>_<datestamp>_<optional identifier>.lic
where the classname and index are
Description Classname Index Wide-open (Free Maestro) open 10 Permanent node-locked nodelocked_perm 20 Node-locked nodelocked 30 Permanent server-based non-library server_perm 40 Permanent library library_perm 50 Server-based non-library server 60 Short-term library library 70 Stub for remote server client 80
An “open” license file is one that contains no node-locked or counted features.
A “permanent” license file is one that contains only permanent (non-expiring or 10-year) features.
A “node-locked” license file (as the term is used above) contains only uncounted, node-locked licenses.
- license_class()¶
Returns the name of the license-file class for this file, based on the contents of the license file.
- license_description()¶
Returns a user-friendly description of the license-file class for this file, based on the contents of the license file.
- is_permanent_nodelocked()¶
Returns true if the license file contains uncounted, node-locked, permanent licenses, and no short-term uncounted, node-locked licenses.
- is_permanent_counted()¶
Returns true if the license file contains permanent counted licenses, and no short-term counted licenses.
- is_permanent_library()¶
Returns true if the license file contains a permanent token library, and no short-term token library.
- is_library()¶
Returns true if the license file contains a token library.
- is_counted()¶
Returns true if this license file includes any counted licenses, which requires a license server.
- is_stub()¶
Returns true if this license file is a stub license, that merely opints to a server but doesn’t include FEATURE/INCREMENT lines.
- is_open()¶
Returns true if this license file can be installed and used on any machine and allows unlimited use of all tokens.
- last_issued()¶
Return the most recent issued date among the licenses in this file.
- empty()¶
Return True if this license contains no features and no SERVER lines.
- need_server()¶
Return True if this license file includes any counted features.
- server_hostport()¶
Return the port@host address for the license server, if this license is for a license server.
- server_host()¶
Return the hostname for the license server, if this license is for a license server.
- redundant_server()¶
Return True if this license specifies a three-machine redundant license server.
- sort()¶
Returns a new License object, sorted in the standard order.
- add_signatures(signatures)¶
Add the given vendor_info signatures to the license. This change is made in place.
A LicfileError is raised if each signature cannot be assigned to a unique license line.
- unsign()¶
Strip signatures from the lines of this License object. This change is made in place.
- cleanup()¶
Remove expired and superseded elements from this license.
SERVER and VENDOR lines are unaffected by this.
Returns a new License object, with the invalid lines removed, and the remaining lines sorted in the standard order.
- merge(oldlic)¶
Merge this license with an older license. User-modifiable settings from the older license will be retained.
Returns a new License object with the merged lines sorted in the standard order.
- validate()¶
Check that the lines in this license file are all valid, and report any errors found to stdput.
WARNING: The validation done here is not comprehensive. There are at least a few errors we could be checking for, but aren’t.
- class schrodinger.application.licensing.flexlm.LicenseLine(tag='', line=None, line_num=0)¶
Bases:
object
A LicenseLine object represents a single line of a FLEXlm license file. This is the base class for the Server, Vendor, Feature, and Package classes.
- __init__(tag='', line=None, line_num=0)¶
- string()¶
- short()¶
- unsign()¶
- print_fields()¶
- is_expired(testdate=None)¶
Test whether the license line has expired.
License lines without an expration date always return False. If a testdate is supplied, it is compared to the expiration date, otherwise the current date is used.
- class schrodinger.application.licensing.flexlm.Server(line=None, line_num=0)¶
Bases:
schrodinger.application.licensing.flexlm.LicenseLine
Server objects represent SERVER lines in the license file.
The format of the SERVER line is: SERVER host hostid [port] [PRIMARY_IS_MASTER] [HEARTBEAT_INTERVAL=seconds]
- __init__(line=None, line_num=0)¶
- print_fields()¶
- hostname()¶
Return the hostname for this server.
- is_nodelocked()¶
Returns true if this server is node-locked.
- class schrodinger.application.licensing.flexlm.Vendor(line=None, line_num=0)¶
Bases:
schrodinger.application.licensing.flexlm.LicenseLine
Vendor objects represent VENDOR lines in the license file.
The format of the VENDOR line is:
VENDOR vendor [vendor_daemon_path] [[OPTIONS=]options_file_path] [[PORT=]port]
- __init__(line=None, line_num=0)¶
- print_fields()¶
- string()¶
- vendor()¶
- pathname()¶
- optionfile()¶
- port()¶
- class schrodinger.application.licensing.flexlm.UseServer(line=None, line_num=0)¶
Bases:
schrodinger.application.licensing.flexlm.LicenseLine
UseServer objects represent USE_SERVER lines in the license file.
The format of the USE_SERVER line is:
USE_SERVER
- __init__(line=None, line_num=0)¶
- class schrodinger.application.licensing.flexlm.Feature(line=None, line_num=0)¶
Bases:
schrodinger.application.licensing.flexlm.LicenseLine
Feature objects represent FEATURE or INCREMENT lines in the license file.
The format of the FEATURE line is:
FEATURE
- __init__(line=None, line_num=0)¶
- short()¶
Return short string representation (no signatures)
- print_fields()¶
- matches(feat)¶
Does the given feature match this one? This is used for assigning RSA signatures to licenses.
It currently compares only the SIGN and SIGN fields, and so can only be used for signed licenses. Assumes that it’s not possible for SIGN fields to match unless SIGN2 fields also match. It doesn’t insist on both SIGN and SIGN2 being present, so it’ll continue to work if we manage to eliminate SIGN2.
- alt_matches(feat)¶
Does the given feature match this one? This is used for assigning RSA signatures to licenses.
This version compares the details of each license line.
- tokens_str()¶
Return the standard string representation of the token count.
- expiration_str()¶
Return the standard string representation of the expiration date.
- issued_str()¶
Return the standard string representation of the issued date.
- start_str()¶
Return the standard string representation of the start date.
- is_nodelocked()¶
Returns true if this license can be used on any host.
- is_counted()¶
Returns true if only a fixed number of tokens are provided.
- is_permanent()¶
Returns true if this license has no expiration date or if it appears to have been issued as a 10-year license.
- is_signed()¶
Does this license line have a signature?
- signature()¶
Return a string representing the signatures for this license line. This is used for recognizing duplicate lines.
When no signatures are present, the full text of the line is used.
- unsign()¶
- supersedes(feat)¶
Does this FEATURE/INCREMENT line supersede the given line?
- sort_index()¶
Get the “sort” field for this line, as an integer.
- add_signature(signature)¶
Add the given vendor_info signature to this line.
If this line doesn’t yet have a ‘vendor_info’ field, one is added to both the text attribute and the fields dict.
- set_sort_index(sort_index)¶
Set the “sort” field for this line to the specified value.
If this line doesn’t yet have a ‘sort’ value, the field is added to both the text attribute and the fields dict.
- class schrodinger.application.licensing.flexlm.Package(line=None, line_num=0)¶
Bases:
schrodinger.application.licensing.flexlm.LicenseLine
A Package object represents a single PACKAGE line in the license file.
The format of the PACKAGE line is:
PACKAGE package vendor [pkg_version] COMPONENTS=pkg_list [OPTIONS=SUITE] [SUPERSEDE[=”p1 p2 …”] ISSUED=date] SIGN=”<…>”
- __init__(line=None, line_num=0)¶
- print_fields()¶
- short()¶
Return short string representation (no signatures)
- issued_str()¶
Return the standard string representation of the issued date.
- supersedes(pkg)¶
Does this PACKAGE line supersede the given line?
- is_signed()¶
Does this license line have a signature?
- signature()¶
Return a string representing the signatures for this license line. This is used for recognizing duplicate lines.
When no signatures are present, the full text of the line is used.
- unsign()¶
- schrodinger.application.licensing.flexlm.find_license_file()¶
Get path to the file defining the license and the actual license file. This is the order of precedence:
$SCHROD_LICENSE_FILE
$LM_LICENSE_FILE
$SCHRODINGER_LICENSE_FALLBACK
$SCHRODINGER_LICENSE
$SCHRODINGER/license
/Library/Application Support/Schrodinger/license (for MacOSX)
Returns the tuple (license_file, source)
- schrodinger.application.licensing.flexlm.is_server(licfile)¶
Returns True if the given “license file” is actually a reference to a license server.
- schrodinger.application.licensing.flexlm.get_linked_path(path)¶
Returns the absolute path for
path
. If it is a symlink the absolute path for the linked file is returned.
- schrodinger.application.licensing.flexlm.shorthost(hostname)¶
Return the short hostname for the given hostname, without the domain name. If hostname is an IP address, it is returned unmodified.
- schrodinger.application.licensing.flexlm.read_license_file(license_file)¶
Read the given license file.
A License object is returned if the given file was an actual FLEXlm license file. Otherwise, a LicfileError exception is raised.