Пример #1
0
  def upload(self, key, fn):
    try:
      sz = os.path.getsize(fn)
    except OSError:
      cloudlog.exception("upload: getsize failed")
      return False

    cloudlog.event("upload", key=key, fn=fn, sz=sz)

    cloudlog.info("checking %r with size %r", key, sz)

    if sz == 0:
      try:
        # tag files of 0 size as uploaded
        setxattr(fn, UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE)
      except OSError:
        cloudlog.event("uploader_setxattr_failed", exc=self.last_exc, key=key, fn=fn, sz=sz)
      success = True
    else:
      cloudlog.info("uploading %r", fn)
      stat = self.normal_upload(key, fn)
      if stat is not None and stat.status_code in (200, 201, 412):
        cloudlog.event("upload_success" if stat.status_code != 412 else "upload_ignored", key=key, fn=fn, sz=sz)
        try:
          # tag file as uploaded
          setxattr(fn, UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE)
        except OSError:
          cloudlog.event("uploader_setxattr_failed", exc=self.last_exc, key=key, fn=fn, sz=sz)
        success = True
      else:
        cloudlog.event("upload_failed", stat=stat, exc=self.last_exc, key=key, fn=fn, sz=sz)
        success = False

    return success
Пример #2
0
 def test_removexattr(self):
     setxattr(self.tmpfn, 'user.test', b'123')
     a = getxattr(self.tmpfn, 'user.test')
     assert a == b'123'
     removexattr(self.tmpfn, 'user.test')
     a = getxattr(self.tmpfn, 'user.test')
     assert a is None
Пример #3
0
 def test_removexattr(self):
     setxattr(self.tmpfn, TestParams.USER_TEST, b'123')
     a = getxattr(self.tmpfn, TestParams.USER_TEST)
     assert a == b'123'
     removexattr(self.tmpfn, TestParams.USER_TEST)
     a = getxattr(self.tmpfn, TestParams.USER_TEST)
     assert a is None
Пример #4
0
import os
from common.xattr import setxattr
from selfdrive.loggerd.uploader import UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE

from selfdrive.loggerd.config import ROOT
for folder in os.walk(ROOT):
    for file1 in folder[2]:
        full_path = os.path.join(folder[0], file1)
        setxattr(full_path, UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE)
Пример #5
0
 def test_listxattr(self):
     setxattr(self.tmpfn, 'user.test1', b'123')
     setxattr(self.tmpfn, 'user.test2', b'123')
     l = listxattr(self.tmpfn)
     assert l == ['user.test1', 'user.test2']
Пример #6
0
 def test_setxattr(self):
     setxattr(self.tmpfn, 'user.test', b'123')
     a = getxattr(self.tmpfn, 'user.test')
     assert a == b'123'