Exemple #1
0
def _install_nodelocked(key=None):
    status = cmds.ragdollLicence(init=True)

    if status in (STATUS_OK, STATUS_FEATURES_CHANGED):
        log.debug("Successfully initialised Ragdoll licence.")

        if key is not None and not cmds.ragdollLicence(isActivated=True):
            log.info("Automatically activating Ragdoll licence")
            return activate(key)

    elif status == STATUS_INET or status == STATUS_INET_DELAYED:
        log.warning("Failed to connect to the internet for activation.")

    elif status == STATUS_ACTIVATE:
        log.warning(
            "Ragdoll is registered, but needs to reconnect with the\n"
            "licence server before continuing. Make sure your computer\n"
            "is connected to the internet, and try again.")

    elif status == STATUS_FAIL:
        log.warning("Couldn't figure out licencing, "
                    "this is a bug. Tell someone.")

    elif status == STATUS_TRIAL_EXPIRED:
        log.warning(
            "Ragdoll trial has expired, head into the chat and tell someone!")

    else:
        log.error("Unexpected error occurred with licencing, "
                  "this is a bug. Tell someone.")

    return status
Exemple #2
0
def data():
    """Return overall information about the current Ragdoll licence"""
    return dict(
        key=cmds.ragdollLicence(serial=True, query=True),

        # Which edition of Ragdoll is this?
        # Standard or Enterprise
        edition="Enterprise",

        # Node-locked or floating
        isFloating=cmds.ragdollLicence(isFloating=True, query=True),

        # Is a licence currently leased?
        hasLease=cmds.ragdollLicence(hasLease=True, query=True),

        # Is the current licence activated?
        isActivated=cmds.ragdollLicence(isActivated=True, query=True),

        # Is the current licence a trial licence?
        isTrial=cmds.ragdollLicence(isTrial=True, query=True),

        # Has the licence not been tampered with?
        isGenuine=cmds.ragdollLicence(isGenuine=True, query=True),

        # Has the licence been verified with the server
        # (requires a connection to the internet)?
        isVerified=cmds.ragdollLicence(isVerified=True, query=True),

        # How many days until this trial expires?
        trialDays=cmds.ragdollLicence(trialDays=True, query=True),

        # How many magic days are left?
        magicDays=cmds.ragdollLicence(magicDays=True, query=True),
    )
Exemple #3
0
def request_lease(ip=None, port=None):
    """Request a licence from `ip` on `port`"""

    assert constants.RAGDOLL_FLOATING, (
        "Lease only relevant for floating licences")

    if not self._installed:
        # Lease is automatically attained during install
        return self.install()

    if not (ip and port):
        try:
            ip, port = constants.RAGDOLL_FLOATING.split(":")
            port = int(port)
        except Exception:
            raise ValueError(
                "Malformatted RAGDOLL_FLOATING environment variable: " %
                constants.RAGDOLL_FLOATING)

    status = cmds.ragdollLicence(requestLease=(ip, port))

    if status == STATUS_OK:
        log.debug("Successfully acquired a lease")

    elif status == STATUS_ALREADY_LEASED:
        log.warning("Already leased")

    elif status == STATUS_NO_FREE_LEASES:
        log.warning("All available licences are occupied")

    else:
        log.warning("Failed to acquire a lease")

    return status
Exemple #4
0
def activate(key):
    """Register your key with the Ragdoll licence server

    Provide your key here to win a prize, the prize of being
    able to use Ragdoll forever and ever!

    """

    status = cmds.ragdollLicence(activate=key)

    if status == STATUS_OK:
        log.info("Successfully activated your Ragdoll licence.")

    elif status == STATUS_FAIL:
        log.error("Failed to activate licence, check your product key.")

    elif status == STATUS_ALREADY_ACTIVATED:
        log.error("Already activated. To activate with a new "
                  "key, call deactivate() first.")

    elif status == STATUS_INET:
        log.error("An internet connection is required to activate.")

    elif status == STATUS_INUSE:
        log.error("Maximum number of activations used.\n"
                  "Try deactivating any previously activated licence.\n"
                  "If you can no longer access the previously activated "
                  "licence, contact [email protected] for "
                  "manual activation.")

    else:
        log.error("Unknown error (%d) occurred, this is a bug." % status)

    return status
Exemple #5
0
def _install_floating():
    ip, port = _parse_environment()
    status = cmds.ragdollLicence(initFloating=True)

    if status == STATUS_OK:
        log.debug("Successfully initialised Ragdoll licence.")
    else:
        log.error(
            "Failed to initialise floating licence, error code '%d'"
            % status
        )
        return status

    status = request_lease(ip, port)

    if status == STATUS_OK:
        log.debug("Successfully leased a Ragdoll licence.")

    elif status == STATUS_INET:
        log.warning("Could not connect to licence server")

    else:
        log.warning(
            "Failed to lease floating licence, error code '%d'"
            % status
        )

    return status
Exemple #6
0
def install(key=None):
    """Initialise licence mechanism

    This must be called prior to calling anything licence related.

    Arguments:
        key (str, optional): Automatically activate upon install

    """

    status = cmds.ragdollLicence(init=True)

    if status == STATUS_OK:
        log.debug("Successfully initialised Ragdoll licence.")

    elif status == STATUS_INET or status == STATUS_INET_DELAYED:
        log.warning(
            "Ragdoll is activated, but failed to verify the activation\n"
            "with the licence servers. You can still use the app for the\n"
            "duration of the grace period.")

    elif status == STATUS_ACTIVATE:
        log.warning(
            "Ragdoll is registered, but needs to reconnect with the\n"
            "licence server before continuing. Make sure your computer\n"
            "is connected to the internet, and try again.")

    elif status == STATUS_FAIL:
        log.warning("Couldn't figure out licencing, "
                    "this is a bug. Tell someone.")

    elif status == STATUS_TRIAL_EXPIRED:
        log.warning(
            "Ragdoll trial has expired, head into the chat and tell someone!")

    else:
        log.error("Unexpected error occurred with licencing, "
                  "this is a bug. Tell someone.")

    if key is not None and not cmds.ragdollLicence(isActivated=True):
        log.info("Automatically activating Ragdoll licence")
        return activate(key)

    return status
Exemple #7
0
def drop_lease():
    status = cmds.ragdollLicence(dropLease=True)

    if status == STATUS_OK:
        log.debug("Successfully dropped lease")

    else:
        log.warning("Failed to drop lease")

    return status
Exemple #8
0
def activate_from_file(fname):
    status = cmds.ragdollLicence(activateFromFile=fname)

    if status == STATUS_OK:
        log.info("Successfully activated Ragdoll!")

    else:
        log.error("There was a problem! Send us this error code "
                  "(%s) and tell us what you did." % status)

    return status
Exemple #9
0
def deactivation_request_to_file(fname):
    status = cmds.ragdollLicence(deactivationRequestToFile=fname)

    if status == STATUS_OK:
        log.info("Successfully deactivated Ragdoll and generated %s\n"
                 "Send this to [email protected]" % fname)

    else:
        log.error("There was a problem! Send us this error code "
                  "(%s) and tell us what you did." % status)

    return status
Exemple #10
0
def request_lease(ip="127.0.0.1", port=13):
    """Request a licence from `ip` on `port`"""
    status = cmds.ragdollLicence(requestLease=(ip, port))

    if status == STATUS_OK:
        log.debug("Successfully acquired a lease")

    elif status == STATUS_NO_FREE_LEASES:
        log.warning("All available licences are occupied")

    else:
        log.warning("Failed to acquire a lease")

    return status
Exemple #11
0
def activate_from_file(fname):
    status = cmds.ragdollLicence(activateFromFile=fname)

    if status == STATUS_OK:
        log.info("Successfully activated Ragdoll!")

    elif not os.path.exists(fname):
        log.error("%s does not appear to exist!" % fname)

    else:
        log.error("There was a problem with '%s'! It seems to exist, "
                  "but may not be valid. Send us this error message (%s) "
                  "and tell us the steps you took to get here." %
                  (fname, status))

    return status
Exemple #12
0
def activation_request_to_file(key, fname):
    fname = fname.replace("\\", "/")  # Just in case
    status = cmds.ragdollLicence(activationRequestToFile=(key, fname))

    if status == STATUS_OK:
        log.info("Successfully generated '%s'\n"
                 "Send this file to [email protected]" % fname)

    elif not os.path.exists(os.path.dirname(fname)):
        log.error("The directory at '%s' does not appear to exist" % fname)

    else:
        log.error("There was a problem with '%s'! "
                  "Send this error message (%s) "
                  "and the steps you took to get here to "
                  "[email protected]." % (fname, status))

    return status
Exemple #13
0
def activate(key):
    """Register your key with the Ragdoll licence server

    Provide your key here to win a prize, the prize of being
    able to use Ragdoll forever and ever!

    """

    status = cmds.ragdollLicence(activate=key)

    if status == STATUS_OK:
        log.info("Successfully activated your Ragdoll licence.")

    elif status == STATUS_FAIL:
        log.error("Failed to activate licence, check your product key.")

    elif status == STATUS_ALREADY_ACTIVATED:
        log.error("Already activated. To activate with a new "
                  "key, call deactivate() first.")

    elif status == STATUS_INET:
        log.error("An internet connection is required to activate.")

    elif status == STATUS_KEY_FOR_TURBOFLOAT:
        log.error("The key provided is meant for a floating licence server, "
                  "this here is for node-locked activation only.")

    elif status == STATUS_IN_VM:
        log.error(
            "This serial cannot be used in a virtual machine, you'll need "
            "a floating licence for that.")

    elif status == STATUS_INUSE:
        log.error("Maximum number of activations used.\n"
                  "Try deactivating any previously activated licence.\n"
                  "If you can no longer access the previously activated "
                  "licence, contact [email protected] for "
                  "manual activation.")

    else:
        log.error("Unknown error (%d) occurred, this is a bug." % status)

    return status
Exemple #14
0
def deactivate():
    """Release currently activated key from this machine

    Moving to another machine? Call this to enable activation
    on another machine.

    """

    status = cmds.ragdollLicence(deactivate=True)

    if status == STATUS_OK:
        log.info("Successfully deactivated Ragdoll licence.")

    elif status == STATUS_TRIAL_EXPIRED:
        log.info("Successfully deactivated Ragdoll licence, "
                 "but your trial has expired.")

    else:
        log.error("Couldn't deactivate Ragdoll licence "
                  "(error code: %s)." % status)

    return status
Exemple #15
0
2. Export more than 10 markers

"""

from nose.tools import (
    assert_equals,
    assert_less,
)

from maya import cmds
from ragdoll import api, dump
from ragdoll.vendor import cmdx

from . import _new

is_unlimited = cmds.ragdollLicence(product=True, query=True) == "enterprise"
is_commercial = not cmds.ragdollLicence(isNonCommercial=True, query=True)


def test_export_10():
    # The user can only ever export 10 markers from a Personal licence
    _new()
    solver = api.createSolver()

    for cube in range(15):
        cube1, _ = cmds.polyCube()
        api.assignMarker(cube1, solver)

    # Only 1 markers will be exported
    data = api.exportPhysics()
    registry = dump.Registry(data)
Exemple #16
0
def reverify():
    return cmds.ragdollLicence(reverify=True)
Exemple #17
0
def current_key():
    """Return the currently activated key, if any"""
    return cmds.ragdollLicence(serial=True)
Exemple #18
0
def data():
    """Return overall information about the current Ragdoll licence"""

    if not self._installed:
        install()

    return dict(
        lastStatus=self._last_status,
        key=cmds.ragdollLicence(serial=True, query=True),

        # Which edition of Ragdoll is this?
        # trial, personal, complete, unlimited or batch
        product=cmds.ragdollLicence(product=True, query=True),

        # Node-locked or floating
        isFloating=cmds.ragdollLicence(isFloating=True, query=True),

        # Is a licence currently leased?
        hasLease=cmds.ragdollLicence(hasLease=True, query=True),

        # Is the current licence activated?
        isActivated=cmds.ragdollLicence(isActivated=True, query=True),

        # Is the current licence a trial licence?
        isTrial=cmds.ragdollLicence(isTrial=True, query=True),

        # Has the licence not been tampered with?
        isGenuine=cmds.ragdollLicence(isGenuine=True, query=True),

        # Has the licence been verified with the server
        # (requires a connection to the internet)?
        isVerified=cmds.ragdollLicence(isVerified=True, query=True),

        # How many days until this trial expires?
        trialDays=cmds.ragdollLicence(trialDays=True, query=True),

        # It's either a Trial or Personal licence
        isNonCommercial=cmds.ragdollLicence(isNonCommercial=True, query=True),

        # How many days until expiration
        expires=cmds.ragdollLicence(expires=True, query=True),
        expiryDays=cmds.ragdollLicence(expiryDays=True, query=True),
        expiry=cmds.ragdollLicence(expiry=True, query=True),

        # Date of Annual Upgrade Program end
        annualUpgradeProgram=cmds.ragdollLicence(annualUpgradeProgram=True,
                                                 query=True),

        # Special flag for anyone having purchased Ragdoll prior to 2022.01.17
        isEarlyBird=cmds.ragdollLicence(isEarlyBird=True, query=True),
    )
Exemple #19
0
def non_commercial():
    return cmds.ragdollLicence(isNonCommercial=True, query=True)
Exemple #20
0
def early_bird():
    return cmds.ragdollLicence(isEarlyBird=True, query=True)