Exemple #1
0
def _write_update_timestamps():
    try:
        from codebay.common import datatypes
        from codebay.l2tpserver import helpers
        from codebay.l2tpserver import constants

        helpers.write_file(constants.TIMESYNC_TIMESTAMP_FILE, datatypes.encode_datetime_to_iso8601_subset(datetime.datetime.utcnow()))
        helpers.write_file(constants.TIMESYNC_PERSISTENT_TIMESTAMP_FILE, datatypes.encode_datetime_to_iso8601_subset(datetime.datetime.utcnow()))
    except:
        if _log is not None:
            _log.exception('writing system time update timestamp failed.')
Exemple #2
0
def _write_update_timestamps():
    try:
        from codebay.common import datatypes
        from codebay.l2tpserver import helpers
        from codebay.l2tpserver import constants

        helpers.write_file(
            constants.TIMESYNC_TIMESTAMP_FILE,
            datatypes.encode_datetime_to_iso8601_subset(
                datetime.datetime.utcnow()))
        helpers.write_file(
            constants.TIMESYNC_PERSISTENT_TIMESTAMP_FILE,
            datatypes.encode_datetime_to_iso8601_subset(
                datetime.datetime.utcnow()))
    except:
        if _log is not None:
            _log.exception('writing system time update timestamp failed.')
Exemple #3
0
def write_datetime_marker_file(fname):
    """Write a timestamp to a markerfile.

    Returns the datetime object used for the timestamp on the
    markerfile.
    """

    timestamp = datetime.datetime.utcnow()

    f = None
    try:
        f = open(fname, 'wb')
        f.write('%s\n' % datatypes.encode_datetime_to_iso8601_subset(timestamp))
    except:
        timestamp = None

    if f is not None:
        f.close()

    return timestamp
 def create_new_demo_license(self, remote_address, remote_port, installation_uuid):
     key = str(licensekey.create_random_license())
     grant_time = datetime.datetime.utcnow()
     f = None
     try:
         f = open(str(os.path.join(msconstants.DEMO_LICENSE_DIRECTORY, key)), 'wb')
         f.write(textwrap.dedent("""\
         grant-time=%s
         remote-address=%s
         remote-port=%s
         installation-uuid=%s
         """ % (datatypes.encode_datetime_to_iso8601_subset(grant_time),
                remote_address.toString(),
                str(remote_port),
                installation_uuid
                )))
     finally:
         if f is not None:
             f.close()
     return key
Exemple #5
0
def write_datetime_marker_file(fname):
    """Write a timestamp to a markerfile.

    Returns the datetime object used for the timestamp on the
    markerfile.
    """

    timestamp = datetime.datetime.utcnow()

    f = None
    try:
        f = open(fname, 'wb')
        f.write('%s\n' %
                datatypes.encode_datetime_to_iso8601_subset(timestamp))
    except:
        timestamp = None

    if f is not None:
        f.close()

    return timestamp
Exemple #6
0
 def _timestamp(dt):
     return datatypes.encode_datetime_to_iso8601_subset(dt)