Beispiel #1
0
def getFileLocation(f):
    filemd = get_quicktime_md(f)
    for key in filemd:
        if not key[-7:] == '_source':
            f.MetaData.Add(key, filemd [key], "Quicktime Metadata")
            mdDefGroup = MetaData.EXPORT_METADATA_GROUP_NAME
        if key == 'com.apple.quicktime.creationdate':
            f.MetaData.Add("Record Time", TimeStamp(Convert.ToDateTime(filemd[key]), True).ToString(), mdDefGroup)
        elif key == 'com.apple.quicktime.make':
            f.MetaData.Add ("Camera Make", filemd [key], mdDefGroup)
        elif key == 'com.apple.quicktime.model':
            f.MetaData.Add ("Camera Model", filemd [key], mdDefGroup)
        elif key == 'com.apple.quicktime.software':
            f.MetaData.Add ("Camera Software", filemd [key], mdDefGroup)
        elif key == 'com.apple.quicktime.camera.identifier':
            f.MetaData.Add ("Camera Identifier", filemd [key], mdDefGroup)
        elif key == 'com.apple.quicktime.comment':
            f.MetaData.Add ("User Comment", filemd[key], mdDefGroup)
        elif key == 'com.apple.quicktime.location.name':
            f.MetaData.Add ("Location Name", filemd[key], mdDefGroup)
        if key == 'com.apple.quicktime.location.ISO6709':
            locval = parseLocation(filemd[key])
            if locval is None:
                continue

            if 'com.apple.quicktime.location.ISO6709_source' in filemd:
                src_ind = filemd['com.apple.quicktime.location.ISO6709_source'][0]
                mdSrc = f.Data.GetSubRange(src_ind, sum(map(len, locval)))
            if mdSrc is None:
                msSrc = MemoryRange()
            f.MetaData.Add("Lat/Lon/Elev", "%s/%s/%s" % tuple(locval), mdSrc, mdDefGroup)

            cLoc = Base.Location()
            cLoc.Deleted = f.Deleted
            cLoc.SourceType = LocationSourceType.Media
            cLoc.Coordinate = Base.Coordinate(float(locval[0]), float(locval[1]), float(locval[2]))
            cLoc.SourceFile = f.AbsolutePath
            # LinkModels(cLoc, f)
            
            if 'com.apple.quicktime.location.ISO6709_source' in filemd:
                src_ind = filemd['com.apple.quicktime.location.ISO6709_source'][0]
                src_ind += len(locval[0])
                if locval[2] is not None and len(locval[2]) > 1:
                    src_ind += len(locval[1])

            if 'com.apple.quicktime.creationdate' in filemd:
                tsStr = filemd['com.apple.quicktime.creationdate']
                cLoc.Time = TimeStamp(Convert.ToDateTime(tsStr), True)
                if 'com.apple.quicktime.creationdate' in filemd:
                    src = filemd['com.apple.quicktime.creationdate_source']

            return cLoc
    return None
Beispiel #2
0
def combinedatetime(isdatei=None, istimei=None):
    import clr
    from System import DateTime
    from System import Convert

    dt = Convert.ToDateTime(isdatei + " " + istimei)
    return dt
def test_str_of_exception():
    """Test the str() representation of an exception."""
    from System import NullReferenceException, Convert, FormatException

    e = NullReferenceException('')
    assert str(e) == ''

    e = NullReferenceException('Something bad happened')
    assert str(e).startswith('Something bad happened')

    with pytest.raises(FormatException) as cm:
        Convert.ToDateTime('this will fail')
Beispiel #4
0
    def getDate(val):
        try:
            if isinstance(val, DateTime):
                formatval = val
            else:
                formatval = Convert.ToDateTime(val)
            ModeDBG.say('\tval {0} formated: {1}'.format(val, formatval))

        except:
            formatval = None
            ModeDBG.say('\tError with val {0}'.format(val))
        return formatval
Beispiel #5
0
    def testStrOfException(self):
        """Test the str() representation of an exception."""
        from System import NullReferenceException
        from System import Convert, FormatException

        e = NullReferenceException('')
        self.failUnless(str(e) == '')

        e = NullReferenceException('Something bad happened')
        self.failUnless(str(e).startswith('Something bad happened'))

        try:
            Convert.ToDateTime('this will fail')
        except FormatException, e:
            self.failUnless(str(e).find('at System.DateTime.Parse') > -1)
Beispiel #6
0
    def testStrOfException(self):
        """Test the str() representation of an exception."""
        from System import NullReferenceException
        from System import Convert, FormatException
        e = NullReferenceException('')
        self.failUnlessEqual(str(e), '')

        e = NullReferenceException('Something bad happened')
        self.failUnless(str(e).startswith('Something bad happened'))

        try:
            Convert.ToDateTime('this will fail')
        except FormatException, e:
            msg = unicode(e).encode(
                "utf8")  # fix for international installation
            self.failUnless(msg.find('System.Convert.ToDateTime') > -1, msg)
Beispiel #7
0
def test_str_of_exception():
    """Test the str() representation of an exception."""
    from System import NullReferenceException, Convert, FormatException

    e = NullReferenceException('')
    assert str(e) == ''

    e = NullReferenceException('Something bad happened')
    assert str(e).startswith('Something bad happened')

    with pytest.raises(FormatException) as cm:
        Convert.ToDateTime('this will fail')

    e = cm.value
    # fix for international installation
    msg = text_type(e).encode("utf8")
    fnd = text_type('System.Convert.ToDateTime').encode("utf8")
    assert msg.find(fnd) > -1, msg
Beispiel #8
0
def daysbetweenbreaks(mixdatei=None,
                      mixtimei=None,
                      breakdatei=None,
                      breaktimei=None):
    from System import DateTime
    from System import TimeSpan
    from System import Convert
    import time
    import re

    daywithintolerance = False
    day = None
    dt = None
    break_message = 'Outside of time requirements '

    if mixdatei and mixtimei and breakdatei and breaktimei:
        mt = is_time_format(mixtimei)
        bt = is_time_format(breaktimei)

        if mt and bt is True:
            mixdt = combinedatetime(mixdatei, mixtimei)
            breakdt = combinedatetime(breakdatei, breaktimei)

            if mixdt <= DateTime.Now and breakdt >= mixdt:
                dateduration = Convert.ToDateTime(
                    breakdatei) - Convert.ToDateTime(mixdatei)
                dt = dateduration.Days
                duration = breakdt - mixdt
                durations = duration.TotalSeconds
                day = duration
                d = duration.Days
                h = duration.Hours
                m = duration.Minutes

                SECONDS_PER_MINUTE = 60
                SECONDS_PER_HOUR = 3600
                SECONDS_PER_DAY = 86400
                dur = 0

                duration_in_sec = duration.TotalSeconds  # Total number of seconds between dates
                #84600-88200 24hr+-.5hr,255600-262800 d3+-1hr,594000-615600 d7+-3hrs,2376000-2462400 d28+-12hrs,4752000-4924800 d56+-24hrs
                seconds_range = [(84599, 88201), (255599, 262801),
                                 (593999, 615601), (2375999, 2462401),
                                 (4751999, 4924801)]

                for sr in seconds_range:
                    for r in sr:
                        if duration_in_sec in range(sr[0], sr[1]):
                            daywithintolerance = True
                            break_message = 'Inside of time requirements'
                            day = duration.Days
                            if day == 0 or day == 2 or day == 6 or day == 27 or day == 55:
                                day = day + 1
                            elif day == 8 or day == 29 or day == 57:
                                day = day - 1
                            else:
                                day = day

                if d <= 1 and dt <= 2:
                    if durations < 84600:
                        dur = 84600 - durations
                    elif durations > 88200:
                        dur = durations - 88200
                elif d >= 2 and dt <= 3 or dt == 4:
                    if durations < 255600:
                        dur = 255600 - durations
                    elif durations > 262800:
                        dur = durations - 262800
                elif d >= 6 and dt <= 7 or dt == 8:
                    if durations < 594000:
                        dur = 594000 - durations
                    elif durations > 615600:
                        dur = durations - 615600
                elif d >= 27 and dt == 28 or dt == 29:
                    if durations < 2376000:
                        dur = 2376000 - durations
                    elif durations > 2462400:
                        dur = durations - 2462400
                elif d >= 55 and dt == 56 or dt == 57:
                    if durations < 4752000:
                        dur = 4752000 - durations
                    elif durations > 4924800:
                        dur = durations - 4924800
                else:
                    dur = durations

                days = dur / SECONDS_PER_DAY
                dur = dur % SECONDS_PER_DAY

                hours = dur / SECONDS_PER_HOUR
                dur = dur % SECONDS_PER_HOUR

                minutes = dur / SECONDS_PER_MINUTE
                dur = dur % SECONDS_PER_MINUTE

                d = int(dt)
                #d = int(days)
                h = int(hours)
                m = int(minutes)

                if daywithintolerance == True:
                    day = str(day)
                elif h == 0 and m == 0:
                    day = str(d)
                elif h == 0:
                    day = str(d) + '     Mn:' + str(m)
                elif m == 0:
                    day = str(d) + '     Hr:' + str(h)
                else:
                    day = str(d) + '     Hr:' + str(h) + ' Mn:' + str(m)

    return day, day, break_message, daywithintolerance
    def determine_status(self):
        if self.statusSet:
            return

        # PMM CHECKS
        checks_sql = "SELECT TOP 20 * FROM [BackgroundChecks] WHERE [PeopleId] = @p1 AND " \
                     "DATEDIFF(DAY, DATEADD(YEAR, -10, GETDATE()), [Updated]) > 0 ORDER BY [Updated] DESC". \
            format(self.person.PeopleId)
        for check in q.QuerySql(checks_sql, self.person.PeopleId):
            check_status = 0

            if check.StatusID >= 2:  # Check has begun
                check_status = check_status | self.Statuses['CHECK_STARTED']

                if check.StatusID == 3:  # Check is complete
                    check_status = check_status | self.Statuses[
                        'CHECK_COMPLETE']

                    if check.IssueCount == 0:
                        check_status = check_status | self.Statuses[
                            'REVIEW_COMPLETE'] | self.Statuses['PASSED']
                    else:
                        check_status = check_status | self.Statuses[
                            'REVIEW_COMPLETE']
                        # TODO: establish a means for checks to pass with issues.

            if check.ServiceCode == "" and check.ReportLabelID == 1:
                # PA Employee

                self.statusHis[
                    'paEmp'] = self.statusHis['paEmp'] | check_status

                if DateTime.Compare(check.Updated, self.Renewals['paEmp']) > 0:
                    self.statusExp[
                        'paEmp'] = self.statusExp['paEmp'] | check_status

                if DateTime.Compare(check.Updated,
                                    self.Expirations['paEmp']) > 0:
                    self.statusCur[
                        'paEmp'] = self.statusCur['paEmp'] | check_status

            if check.ServiceCode == "ComboPS":
                # PA Volunteer

                self.statusHis[
                    'paVol'] = self.statusHis['paVol'] | check_status

                if DateTime.Compare(check.Updated, self.Renewals['paVol']) > 0:
                    self.statusExp[
                        'paVol'] = self.statusExp['paVol'] | check_status

                if DateTime.Compare(check.Updated,
                                    self.Expirations['paVol']) > 0:
                    self.statusCur[
                        'paVol'] = self.statusCur['paVol'] | check_status

            if check.ServiceCode == "Combo" or check.ServiceCode == "ComboPS" or check.ServiceCode == "":
                # Basic

                self.statusHis[
                    'basic'] = self.statusHis['basic'] | check_status

                if DateTime.Compare(check.Updated, self.Renewals['basic']) > 0:
                    self.statusExp[
                        'basic'] = self.statusExp['basic'] | check_status

                if DateTime.Compare(check.Updated,
                                    self.Expirations['basic']) > 0:
                    self.statusCur[
                        'basic'] = self.statusCur['basic'] | check_status

        # MINOR'S WAIVER
        if self.person.BirthYear is not None and self.person.BirthDate > self.Expirations[
                'isMin']:
            self.statusCur['isMin'] = self.Statuses['CHECK_STARTED'] | self.Statuses['CHECK_COMPLETE'] | \
                                      self.Statuses['REVIEW_COMPLETE'] | self.Statuses['PASSED']
        if self.person.BirthYear is not None and self.person.BirthDate > self.Renewals[
                'isMin']:
            self.statusExp['isMin'] = self.Statuses['CHECK_STARTED'] | self.Statuses['CHECK_COMPLETE'] | \
                                      self.Statuses['REVIEW_COMPLETE'] | self.Statuses['PASSED']

        # FBI Fingerprinting
        for doc in self.person.VolunteerForms:
            rx = Regex(
                "(?<docType>\w+)\s+(?<date>[0-9]{1,2}/[0-9]{1,2}/[0-9]{4})",
                RegexOptions.Compiled | RegexOptions.IgnoreCase)
            rm = rx.Match(doc.Name)

            if not rm.Success:
                continue

            if rm.Groups['docType'].Value.ToLower() == "fbi":
                dt = Convert.ToDateTime(rm.Groups['date'].Value)

                # TODO impose some form of verification here.
                check_status = self.Statuses['CHECK_STARTED'] | self.Statuses['CHECK_COMPLETE'] | \
                               self.Statuses['REVIEW_COMPLETE'] | self.Statuses['PASSED']

                self.statusHis[
                    'fingr'] = self.statusHis['fingr'] | check_status

                if DateTime.Compare(dt, self.Renewals['fingr']) > 0:
                    self.statusExp[
                        'fingr'] = self.statusExp['fingr'] | check_status

                if DateTime.Compare(dt, self.Expirations['fingr']) > 0:
                    self.statusCur[
                        'fingr'] = self.statusCur['fingr'] | check_status

        self.statusSet = True