Exemple #1
0
def fetch_info(id, callback):
    query = urllib.urlencode({
        'id': id,
        'nocloud': 1
        })
    url = URLS['DEBUG_PROJECT'] + '?' + query
    params = {'user_token': settings.token}
    ApiPost(url, params, callback).start()
Exemple #2
0
def delete(project_id, project_path, file_path):
    url = URLS['DELETE_FILE']
    params = {
        'user_token': settings.token,
        'id': project_id,
        'file': os.path.relpath(file_path, project_path)
    }

    def after(res):
        if res['errno'] != 0:
            return
        save_changes(project_id)

    ApiPost(url, params, after).start()
Exemple #3
0
def delete(path, callback=None):
    url = URLS['DELETE_PROJECT']
    params = {
        'user_token': settings.token,
        'id': get_id(path)
    }

    def after_delete(res):
        if res['errno']:
            return
        os.remove(os.path.join(path, settings.project_sign))
        callback and callback()

    ApiPost(url, params, after_delete).start()
Exemple #4
0
    def on_done(self, path, name):
        self.config['id'] = name

        url = URLS['CONFIG_API']
        params = {'product_id': 1, 'component_name': name, 'info_type': 1}

        def after(res):
            if res['errno']:
                return
            self.config['version'] = res['data']['version']
            f = open(os.path.join(path, 'config.json'), 'w')
            f.write(json.dumps(self.config, indent=4))
            f.close()

        ApiPost(url, params, after).start()
Exemple #5
0
def mkdir(project_id, project_path, file_path):
    print 'ADD DIR'
    url = URLS['ADD_DIR']
    params = {
        'user_token': settings.token,
        'id': project_id,
        'dir': os.path.relpath(file_path, project_path)
    }

    def after(res):
        if res['errno'] != 0:
            return
        save_changes(project_id)

    ApiPost(url, params, after).start()
Exemple #6
0
def put(project_id, project_path, file_path):
    print 'PUT FILE'
    url = URLS['PUT_FILE_CONTENT']
    params = {
        'user_token': settings.token,
        'id': project_id,
        'file': os.path.relpath(file_path, project_path),
        'content': getBase64Content(file_path)
    }

    def after(res):
        if res['errno'] != 0:
            return
        save_changes(project_id)

    ApiPost(url, params, after).start()
Exemple #7
0
def get_and_write(project_id, filename, path, callback=None):
    file_loc = os.path.join(path, filename)
    if os.path.isfile(file_loc):
        if callback is not None:
            callback()
        return

    url = URLS['GET_FILE_CONTENT']
    params = {'user_token': settings.token, 'id': project_id, 'file': filename}

    def after_get_content(res):
        f = open(file_loc, 'w')
        content = base64.b64decode(res)
        f.write(content)
        f.close()

        if callback is not None:
            callback()

    ApiPost(url, params, after_get_content).start()
Exemple #8
0
    def run(self, dirs):
        path = dirs[0]
        zippath = compress(path)
        f = open(zippath, 'rb')
        bs = base64.encodestring(f.read())
        f.close()

        url = 'http://devtest.nuomi.com/openplatform/release/filesave'
        params = {
            'fileType': '.zip',
            'token': settings.token,
            'componentName': project.get_comp_name(path),
            'bs': bs
        }

        def after(res):
            os.remove(zippath)
            if res['errno']:
                return
            webbrowser.open_new_tab(
                'http://devtest.nuomi.com/#/package/list?istest=1')

        ApiPost(url, params, after).start()