Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Can't save file content #175

Closed
Closed
@araichev

Description

@araichev

Hi there,

Using Python 3.5 and python-gitlab 0.16, i can't save some file content to Gitlab.
More specifically, running this code

from pathlib import Pathpath = Path('..')/'test.txt'  # Text file with contents "Goodbye, world"project_id = 'secret_ID'file_path = 'data/' + path.namef = gl.project_files.get(file_path=file_path, ref='master', project_id=project_id)   f.content = base64.b64encode(path.open('rb').read())f.save(branch_name='master', commit_message='Updated ' + file_path , encoding='base64')

i get this error

TypeError                                 Traceback (most recent call last)<ipython-input-17-7015cf3aaaad> in <module>()     12      13 f.content = base64.b64encode(path.open('rb').read())---> 14 f.save(branch_name='master', commit_message='Updated ' + file_path , encoding='base64')/home/hidden_user/.virtualenvs/hidden_dir/lib/python3.5/site-packages/gitlab/objects.py in save(self, **kwargs)    318     def save(self, **kwargs):    319         if self._from_api:--> 320             self._update(**kwargs)    321         else:    322             self._create(**kwargs)/home/hidden_user/.virtualenvs/hidden_dir/lib/python3.5/site-packages/gitlab/objects.py in _update(self, **kwargs)    313             raise NotImplementedError    314 --> 315         json = self.gitlab.update(self, **kwargs)    316         self._set_from_dict(json)    317 /home/hidden_user/.virtualenvs/hidden_dir/lib/python3.5/site-packages/gitlab/__init__.py in update(self, obj, **kwargs)    621     622         # build data that can really be sent to server--> 623         data = obj._data_for_gitlab(extra_parameters=kwargs, update=True)    624     625         r = self._raw_put(url, data=data, content_type='application/json')/home/hidden_user/.virtualenvs/hidden_dir/lib/python3.5/site-packages/gitlab/objects.py in _data_for_gitlab(self, extra_parameters, update, as_json)    227         data.update(extra_parameters)    228 --> 229         return json.dumps(data) if as_json else data    230     231     @classmethod/usr/lib/python3.5/json/__init__.py in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)    228         cls is None and indent is None and separators is None and    229         default is None and not sort_keys and not kw):--> 230         return _default_encoder.encode(obj)    231     if cls is None:    232         cls = JSONEncoder/usr/lib/python3.5/json/encoder.py in encode(self, o)    196         # exceptions aren't as detailed.  The list call should be roughly    197         # equivalent to the PySequence_Fast that ''.join() would do.--> 198         chunks = self.iterencode(o, _one_shot=True)    199         if not isinstance(chunks, (list, tuple)):    200             chunks = list(chunks)/usr/lib/python3.5/json/encoder.py in iterencode(self, o, _one_shot)    254                 self.key_separator, self.item_separator, self.sort_keys,    255                 self.skipkeys, _one_shot)--> 256         return _iterencode(o, 0)    257     258 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,/usr/lib/python3.5/json/encoder.py in default(self, o)    177     178         """--> 179         raise TypeError(repr(o) + " is not JSON serializable")    180     181     def encode(self, o):TypeError: b'R29vZGJ5ZSwgd29ybGQK' is not JSON serializable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp