def update_project_metadata(self, script_id, remote_content, local_code_path, local_manifest_path):
     """
     Update a script project's remote metadata with local metadata. 
     
     Args:
         script_id: id associated to a script project.
         remote_content: A Content object
         
     Returns:
         If request is successful, a Content object is returned in the form of json
     """
     file_list = remote_content['files']
   
     code_index = self._get_code_file_index(file_list)
     
     file_list[code_index]['source'] = str(intent_parser_utils.load_file(local_code_path)).strip()
     
     manifest_index = self._get_manifest_file_index(file_list)
     file_list[manifest_index] = intent_parser_utils.load_json_file(local_manifest_path)
     request = {'files' : file_list}
     
     content_obj = self._service.projects().updateContent(
         body=request,
         scriptId=script_id).execute()
     return content_obj
Exemple #2
0
    def set_project_metadata(self, script_id, project_metadata, user_obj,
                             local_code_path, local_manifest_path,
                             code_file_name):
        """
        Set project's remote metadata with local metadata. 
        This includes updating manifest file and adding to project metadata a SERVER_JS file for the server code.
         
        Args:
            script_id: id associated to a script project.
         
        Returns:
            If request is successful, a Content object representing the metadata is returned in the json format.
        """

        file_list = project_metadata['files']
        manifest_index = self._get_manifest_file_index(file_list)
        file_list[manifest_index] = intent_parser_utils.load_json_file(
            local_manifest_path)

        source = str(intent_parser_utils.load_file(local_code_path)).strip()
        code_functions = script_addon_utils.get_function_names_from_js_file(
            local_code_path)

        d = datetime.datetime.utcnow()
        created_time = d.isoformat("T") + "Z"

        code_file = {
            "name": code_file_name,
            "type": 'SERVER_JS',
            "source": source,
            "lastModifyUser": user_obj,
            "createTime": created_time,
            "updateTime": created_time,
            "functionSet": code_functions
        }

        file_list.append(code_file)
        request = {'files': file_list}

        content_obj = self._service.projects().updateContent(
            body=request, scriptId=script_id).execute()
        return content_obj
Exemple #3
0
 def __init__(self):
     _curr_path = os.path.dirname(os.path.realpath(__file__))
     html_file = intent_parser_utils.load_file(os.path.join(_curr_path, 'analyze_sidebar.html'))
     self.html = html_file 
Exemple #4
0
 def __init__(self):
     _curr_path = os.path.dirname(os.path.realpath(__file__))
     html_file = intent_parser_utils.load_file(os.path.join(_curr_path, 'experimental_protocol_dialog.html'))
     self.html = html_file
Exemple #5
0
 def __init__(self):
     _curr_path = os.path.dirname(os.path.realpath(__file__))
     html_file = intent_parser_utils.load_file(os.path.join(_curr_path, 'create_parameter_table.html'))
     self.html = html_file