GitHub PullRequestReviewCommentEvent at 2014-05-02 20:52:33
Repository: coi-services
Actor: lukecampbell
Payload: {"comment":{"url":"https://api.github.com/repos/ooici/coi-services/pulls/comments/12247730","id":12247730,"diff_hunk":"@@ -1043,8 +1103,573 @@ def _get_current_deployment(self, dep_objs, for_activate=True):\n         if len(filtered_dep) == 1:\n             return filtered_dep[0][2]\n \n+        log.warn(\"Cannot determine current deployment unambiguously - choosing earliest start date\")\n         filtered_dep = sorted(filtered_dep, key=lambda x: x[0])\n-        return filtered_dep[-1][2]\n+        return filtered_dep[0][2]\n+\n+    def _clone_res_obj(self, res_obj, clone_id):\n+        res_pre_id = self._get_alt_id(res_obj, \"PRE\")\n+        resnew_pre_id = res_pre_id + \"_\" + clone_id\n+        if self._get_resource_by_alt_id(\"PRE\", resnew_pre_id):\n+            raise BadRequest(\"%s %s clone %s already exists\", res_obj.type_, res_obj._id, resnew_pre_id)\n+\n+        res_dict = res_obj.__dict__.copy()\n+        res_type = res_dict.pop(\"type_\")\n+        for attr in [\"_id\", \"_rev\", \"lcstate\", \"availability\", \"alt_ids\"]:\n+            res_dict.pop(attr)\n+\n+        newres_obj = IonObject(res_type, **res_dict)\n+        self._set_alt_id(newres_obj, \"CLONE:%s\" % res_obj._id)\n+        if res_pre_id:\n+            self._set_alt_id(newres_obj, \"PRE:\" + resnew_pre_id)\n+        newres_obj.name = res_obj.name + \" (cloned)\"\n+        newres_obj.description = \"Cloned from %s\" % res_obj._id\n+\n+        return newres_obj, res_pre_id, resnew_pre_id\n+\n+    def _clone_org_share(self, res_id, newres_id):\n+        orgms = OrgManagementServiceProcessClient(process=self)\n+        # Share in Orgs\n+        org_ids, _ = self.rr.find_subjects(RT.Org, PRED.hasResource, res_id, id_only=True)\n+        for org_id in org_ids:\n+            if self.verbose:\n+                log.debug(\"Share cloned resource %s in org %s\", newres_id, org_id)\n+            orgms.share_resource(org_id, newres_id, headers=self._get_system_actor_headers())\n+\n+    def _clone_device(self, res_obj, clone_id):\n+        ims = InstrumentManagementServiceProcessClient(process=self)\n+\n+        resource_id = res_obj._id\n+        newdev_obj, dev_pre_id, devnew_pre_id = self._clone_res_obj(res_obj, clone_id)\n+        newdev_obj.serial_number = \"\"\n+        newdev_obj.ooi_property_number = \"\"\n+        if newdev_obj.temporal_bounds:\n+            newdev_obj.temporal_bounds.start_datetime = str(int(time.time()))\n+        else:\n+            newdev_obj.temporal_bounds = IonObject(OT.TemporalBounds)\n+            newdev_obj.temporal_bounds.start_datetime = str(int(time.time()))\n+            newdev_obj.temporal_bounds.end_datetime = \"2650838400\"  # 2054-01-01","path":"ion/agents/agentctrl.py","position":506,"original_position":506,"commit_id":"9c6dc54ce219236adbe4dfdcb8152efe5755431c","original_commit_id":"9c6dc54ce219236adbe4dfdcb8152efe5755431c","user":{"login":"lukecampbell","id":1155163,"avatar_url":"https://avatars.githubusercontent.com/u/1155163?","gravatar_id":"1e1293460f0f8b71708a8f2a2bbf9d2c","url":"https://api.github.com/users/lukecampbell","html_url":"https://github.com/lukecampbell","followers_url":"https://api.github.com/users/lukecampbell/followers","following_url":"https://api.github.com/users/lukecampbell/following{/other_user}","gists_url":"https://api.github.com/users/lukecampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/lukecampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukecampbell/subscriptions","organizations_url":"https://api.github.com/users/lukecampbell/orgs","repos_url":"https://api.github.com/users/lukecampbell/repos","events_url":"https://api.github.com/users/lukecampbell/events{/privacy}","received_events_url":"https://api.github.com/users/lukecampbell/received_events","type":"User","site_admin":false},"body":"Just a note, 32-bit systems can't deal with dates past 2038 and we've started seeing bugs creep up where we use int32s to represent time. This is fine as is because it's a string but just a note. \r\n\r\nI don't know if we intend to support 32-bit systems in any case.","created_at":"2014-05-02T20:52:33Z","updated_at":"2014-05-02T20:52:33Z","html_url":"https://github.com/ooici/coi-services/pull/2060#discussion_r12247730","pull_request_url":"https://api.github.com/repos/ooici/coi-services/pulls/2060","_links":{"self":{"href":"https://api.github.com/repos/ooici/coi-services/pulls/comments/12247730"},"html":{"href":"https://github.com/ooici/coi-services/pull/2060#discussion_r12247730"},"pull_request":{"href":"https://api.github.com/repos/ooici/coi-services/pulls/2060"}}}}