def importChannels(self): """ Import channels from the old project to the new project. """ # make sure the ocp project exists pr = Project.objects.get(project_name=self.newproject_name) for channel in self.oldchannels.keys(): ch = Channel() ch.project = pr ch.channel_name = channel ch.channel_description = 'Imported from oldchannel schema.' ch.channel_type = 'image' ch.resolution = 0 ch.propagate = self.propagate ch.channel_datatype = self.datatype ch.readonly = self.readonly ch.exceptions = 0 ch.startwindow = 0 ch.endwindow = 0 ch.default = False try: ch.save() pd = ocpcaproj.OCPCAProjectsDB() pd.newOCPCAChannel(pr.project_name, ch.channel_name) print "Created channel {}".format(channel) except Exception, e: print "[ERROR]: {}".format(e) exit()
def importChannels(self): """ Import channels from the old project to the new project. """ # make sure the ocp project exists pr = Project.objects.get(project_name=self.newproject_name) for channel in self.oldchannels.keys(): ch = Channel() ch.project = pr ch.channel_name = channel ch.channel_description = 'Imported from oldchannel schema.' ch.channel_type = 'image' ch.resolution = 0 ch.propagate = self.propagate ch.channel_datatype = self.datatype ch.readonly = self.readonly ch.exceptions = 0 ch.startwindow = 0 ch.endwindow = 0 ch.default = False try: ch.save() pd = ocpcaproj.OCPCAProjectsDB() pd.newOCPCAChannel( pr.project_name, ch.channel_name ) print "Created channel {}".format(channel) except Exception, e: print "[ERROR]: {}".format(e) exit()
def extractChannelDict(ch_dict, channel_only=False): """Generate a channel object from the JSON flle""" ch = Channel() try: #ch.pk = ch_dict['channel_name'] ch.channel_name = ch_dict['channel_name'] ch.channel_datatype = ch_dict['datatype'] ch.channel_type = ch_dict['channel_type'] if not channel_only: data_url = ch_dict['data_url'] file_format = ch_dict['file_format'] file_type = ch_dict['file_type'] except Exception, e: print "Missing requried fields" raise