~jstys-z/helioviewer.org/client5

« back to all changes in this revision

Viewing changes to install/hvpull/servers/__init__.py

  • Committer: Keith Hughitt
  • Date: 2012-04-23 16:02:25 UTC
  • mto: This revision was merged to the branch mainline in revision 732.
  • Revision ID: keith.hughitt@nasa.gov-20120423160225-xzoh82ejf37c8yr7
Incorporated HVPull code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Classes for working with known data servers"""
 
2
import os
 
3
import datetime
 
4
 
 
5
class DataServer:
 
6
    """Class for interacting with data servers."""
 
7
    def __init__(self, uri):
 
8
        self.uri = uri
 
9
        self.pause = datetime.timedelta(minutes=3)
 
10
        
 
11
        # Example: 2011_11_17__08_13_08_13__SDO_AIA_AIA_304.jp2
 
12
        self.filename_regex = (
 
13
            "^(?P<year>\d{4})_(?P<month>\d{2})_(?P<day>\d{2})__" +
 
14
            "(?P<hour>\d{2})_(?P<min>\d{2})_(?P<sec>\d{2})_" + 
 
15
            "(?P<microsec>\d{2,3})__" +
 
16
            "(?P<obs>[a-zA-Z0-9]{3})_(?P<inst>[a-zA-Z0-9]{3})_" +
 
17
            "(?P<det>[a-zA-Z0-9]{3})_(?P<meas>[a-zA-Z0-9]{2,11})\.jp2$")
 
18
 
 
19
    def get_starttime(self):
 
20
        """Default start time to use when retrieving data"""
 
21
        return datetime.datetime.utcnow() - datetime.timedelta(days=1)
 
22
   
 
23
    def get_dates(self, start, end):
 
24
        """Get a complete list of dates between the start and the end time"""
 
25
        return None
 
26
    
 
27
    def get_file_regex(self):
 
28
        """Returns a regex which described the expected format of filenames on
 
29
        the server"""
 
30
        return self.filename_regex
 
31
    
 
32
    def get_nicknames(self):
 
33
        """Get a list of nicknames at the root of the data server"""
 
34
        pass
 
35
 
 
36
    def get_measurements(self, nicknames, dates):
 
37
        """Get a list of all the URIs down to the measurement"""
 
38
        return None
 
39
    
 
40
    def get_uri(self):
 
41
        """Return the server URI"""
 
42
        return self.uri
 
43
 
 
44
    def get_locations(self, start, end):
 
45
        """This scans the URI and finds all the possible nicknames, then adds in the requested
 
46
        dates, then scans for all the measurements.
 
47
        """
 
48
        nicknames = self.get_nicknames()
 
49
        #dates = self.get_dates(self,start,end)
 
50
        #measurements = self.get_measurements(self,nicknames,dates)
 
51
        #return measurements