コード例 #1
0
    def split(self, line):
        line_buoy = re.match("(.*): EMERGENCY buoy (\d+) (.*)", line)
        line_coord = re.match(
            ".*: EMERGENCY ([NS])(\d+)deg(\d+\.\d+)mn ([EW])(\d+)deg(\d+\.\d+)mn",
            line)

        if line_buoy:
            iso8601_date = re.match("(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)",
                                    line_buoy.group(1))
            if self.date is None and self.cause is None:
                if iso8601_date:
                    self.date = utils.totimestamp(
                        datetime.datetime.strptime(line_buoy.group(1),
                                                   "%Y-%m-%dT%H:%M:%S"))
                else:
                    self.date = utils.totimestamp(
                        datetime.datetime.strptime(line_buoy.group(1),
                                                   "%Y%m%d-%Hh%Mmn%S"))
                self.cause = line_buoy.group(3).decode('ascii', 'ignore')
                self._state = "In_progress"
            else:
                self._state = "Interrupted"
        if line_coord:
            if self.latitude is None and self.longitude is None:
                if line_coord.group(1) == "N":
                    sign = 1
                elif line_coord.group(1) == "S":
                    sign = -1
                self.latitude = sign * (float(line_coord.group(2)) +
                                        float(line_coord.group(3)) / 60.)
                if line_coord.group(4) == "E":
                    sign = 1
                elif line_coord.group(4) == "W":
                    sign = -1
                self.longitude = sign * (float(line_coord.group(5)) +
                                         float(line_coord.group(6)) / 60.)
                self._state = "In_progress"
            else:
                self._state = "Interrupted"
        if not self.buoy is None \
        and not  self.date is None\
        and not  self.latitude is None \
        and not  self.longitude is None \
        and not self.cause is None:
            self._state = "Full"
コード例 #2
0
ファイル: __init__.py プロジェクト: SUNET/lobo2
def renew_token(token_id):
    token = auth.get_token(token_id)
    if token is None:
        abort(404)

    token.expires += timedelta(days=30)
    token.save()

    return jsonify(dict(token_id=token_id, expires_ts=totimestamp(token.expires), expires_txt="%s" % token.expires))
コード例 #3
0
ファイル: fromGIFT.py プロジェクト: nburlot/cn_app
 def __init__(self):
     now = datetime.utcnow()  
     self.id = int(utils.totimestamp(now))
     self.gift_src = ''
     self.type = ''
     self.title = ''
     self.text = ''
     self.text_format = 'moodle' # possible values = html, moodle, plain and markdown
     self.answers = [] # a list of possible answers objects
     self.poststate = '' # bit of text possibly added in case of MISSINGWORD questions
     self.question_is_true = True # for TRUEFALSE questions, by default considered TRUE
     self.global_feedback = ''
     self.global_feedback_format = '[markdown]'
     self.feedback_for_right = '' # for TRUEFALSE questions, given when giving the right answer
     self.feedback_for_wrong = '' # for TRUEFALSE questions, given when giving the wrong answer
コード例 #4
0
ファイル: fromGIFT.py プロジェクト: nburlot/cn_app
 def __init__(self):
     now = datetime.utcnow()
     self.id = int(utils.totimestamp(now))
     self.gift_src = ''
     self.type = ''
     self.title = ''
     self.text = ''
     self.text_format = 'moodle'  # possible values = html, moodle, plain and markdown
     self.answers = []  # a list of possible answers objects
     self.poststate = ''  # bit of text possibly added in case of MISSINGWORD questions
     self.question_is_true = True  # for TRUEFALSE questions, by default considered TRUE
     self.global_feedback = ''
     self.global_feedback_format = '[markdown]'
     self.feedback_for_right = ''  # for TRUEFALSE questions, given when giving the right answer
     self.feedback_for_wrong = ''  # for TRUEFALSE questions, given when giving the wrong answer
コード例 #5
0
    def _load_files(self, base, old=[]):
        old_map = dict([(os.path.join(f.path, f.name), f) for f in old])
        new, changed = [], False

        for root, dirs, files in os.walk(base):
            for name in files:
                fullname = os.path.join(root, name)
                name_on_storage = '%s.%s' % (uuid.uuid1().hex, name)
                path = os.path.dirname(os.path.relpath(fullname, base))

                new_file = old_map.get(os.path.join(path, name))
                if new_file:
                    # Check if it's new enough.
                    old_modified = int(
                        totimestamp(
                            new_file.the_file.storage.modified_time(
                                new_file.the_file.name)))
                    new_modified = int(os.stat(fullname).st_mtime)
                    if new_modified > old_modified:
                        f = DJFile(open(fullname))
                        new_file = File(name=name, path=path, size=f.size)
                        new_file.the_file.save(name_on_storage, f)
                        changed = True
                    else:
                        new_file.reuse = True
                else:
                    f = DJFile(open(fullname))
                    new_file = File(name=name, path=path, size=f.size)
                    new_file.the_file.save(name_on_storage, f)
                    changed = True

                new.append(new_file)

        if len(old) != len(new):
            changed = True

        for f in old:
            if not getattr(f, 'reuse', False):
                f.the_file.delete()
                f.delete()

        return new, changed
コード例 #6
0
ファイル: models.py プロジェクト: sachinrase/sin
    def _load_files(self, base, old=[]):
        old_map = dict([(os.path.join(f.path, f.name), f) for f in old])
        new, changed = [], False

        for root, dirs, files in os.walk(base):
            for name in files:
                fullname = os.path.join(root, name)
                name_on_storage = "%s.%s" % (uuid.uuid1().hex, name)
                path = os.path.dirname(os.path.relpath(fullname, base))

                new_file = old_map.get(os.path.join(path, name))
                if new_file:
                    # Check if it's new enough.
                    old_modified = int(totimestamp(new_file.the_file.storage.modified_time(new_file.the_file.name)))
                    new_modified = int(os.stat(fullname).st_mtime)
                    if new_modified > old_modified:
                        f = DJFile(open(fullname))
                        new_file = File(name=name, path=path, size=f.size)
                        new_file.the_file.save(name_on_storage, f)
                        changed = True
                    else:
                        new_file.reuse = True
                else:
                    f = DJFile(open(fullname))
                    new_file = File(name=name, path=path, size=f.size)
                    new_file.the_file.save(name_on_storage, f)
                    changed = True

                new.append(new_file)

        if len(old) != len(new):
            changed = True

        for f in old:
            if not getattr(f, "reuse", False):
                f.the_file.delete()
                f.delete()

        return new, changed
コード例 #7
0
ファイル: auth.py プロジェクト: SUNET/lobo2
def _totimestamp(ts):
    if not ts or ts is None:
        return ''
    return totimestamp(ts)
コード例 #8
0
    def split(self, line, mdives, path, filterDate):
        line_buoy = re.match(".* >>> BUOY (\d+) (\d+-\d+-\d+T\d+:\d+:\d+) <<<",
                             line)
        line_coord = re.match(
            ".*: ([NS])(\d+)deg(\d+\.\d+)mn, ([EW])(\d+)deg(\d+\.\d+)mn", line)
        line_dop = re.match(".* hdop (.*), vdop (.*)", line)
        line_bat = re.match(".* Vbat (\d+)mV \(min (\d+)mV\)", line)
        line_Pint = re.match(".* Pint (\d+)Pa", line)
        line_Pext = re.match(".* Pext (-?\d+)mbar \(range (-?\d+)mbar\)", line)
        begin = 0
        end = 0
        buffdate = 0

        if self.buoy in filterDate.keys():
            begin = filterDate[self.buoy][0]
            end = filterDate[self.buoy][1]
        else:
            begin = datetime.datetime(1000, 1, 1)
            end = datetime.datetime(3000, 1, 1)

        if line_buoy:
            buffdate = datetime.datetime.strptime(line_buoy.group(2),
                                                  "%Y-%m-%dT%H:%M:%S")
        if buffdate == 0:
            buffdate = datetime.datetime(1000, 1, 1)
        if begin < buffdate:
            self.deployed = True
        if line_buoy:
            if self.date is None:
                self.date = utils.totimestamp(buffdate)
                for dive in mdives:
                    if (self.date <= dive.end_date.timestamp
                            and self.date >= dive.date.timestamp):
                        divefiles = os.listdir(path + "/" + self.buoy +
                                               "/processed/" +
                                               dive.directory_name)
                        for divefile in divefiles:
                            divefilepath = "/" + dive.directory_name + "/" + divefile
                            if divefilepath not in self.divepath:
                                self.divepath.append("/" +
                                                     dive.directory_name +
                                                     "/" + divefile)

                self._state = "In_progress"
            else:
                self._state = "Interrupted"
        if line_coord:
            if self.latitude is None and self.longitude is None:
                if line_coord.group(1) == "N":
                    sign = 1
                elif line_coord.group(1) == "S":
                    sign = -1
                self.latitude = sign * (float(line_coord.group(2)) +
                                        float(line_coord.group(3)) / 60.)
                if line_coord.group(4) == "E":
                    sign = 1
                elif line_coord.group(4) == "W":
                    sign = -1
                self.longitude = sign * (float(line_coord.group(5)) +
                                         float(line_coord.group(6)) / 60.)
                self._state = "In_progress"
            else:
                self._state = "Interrupted"
        if line_dop:
            if self.hdop is None and self.vdop is None:
                self.hdop = line_dop.group(1)
                self.vdop = line_dop.group(2)
                self._state = "In_progress"
            else:
                self._state = "Interrupted"
        if line_bat:
            if self.vbat is None and self.vbatmin is None:
                self.vbat = int(line_bat.group(1))
                self.vbatmin = int(line_bat.group(2))
                self._state = "In_progress"
            else:
                self._state = "Interrupted"
        if line_Pint:
            if not self.pint:
                self.pint = int(line_Pint.group(1))
                self._state = "In_progress"
            else:
                self._state = "Interrupted"
        if line_Pext:
            if self.pext is None and self.pextrange is None:
                self.pext = int(line_Pext.group(1))
                self.pextrange = int(line_Pext.group(2))
                self._state = "In_progress"
            else:
                self._state = "Interrupted"
        if not self.buoy is None \
        and not  self.date is None\
        and not  self.latitude is None \
        and not  self.longitude is None \
        and not  self.hdop is None \
        and not  self.vdop is None \
        and not  self.vbat is None \
        and not  self.vbatmin is None \
        and not  self.pint is None \
        and not  self.pext is None \
        and not  self.pextrange is None:
            self._state = "Full"
コード例 #9
0
ファイル: models.py プロジェクト: thaingo/sin
 def get_unique_name(self):
   return "%s_%s" % (self.name, long(totimestamp(self.created)*1000))
コード例 #10
0
ファイル: models.py プロジェクト: rockysays/sin
 def get_unique_name(self):
     return "%s_%s" % (self.name, long(totimestamp(self.created) * 1000))