

def UploadActivity(self, serviceRecord, activity):
    format = serviceRecord.GetConfiguration()['Format']
    if (format == 'tcx'):
        if ('tcx' in fpath.PrerenderedFormats):
            logger.debug('Using prerendered TCX')
            data = activity.PrerenderedFormats['tcx']
        else:
            data = TCXIO.Dump(activity)
    elif ('gpx' in activity.PrerenderedFormats):
        logger.debug('Using prerendered GPX')
        data = activity.PrerenderedFormats['gpx']
    else:
        data = GPXIO.Dump(activity)
    dbcl = self._getClient(serviceRecord)
    fname = ((self._format_file_name(serviceRecord.GetConfiguration()['Filename'], activity)[:250] + '.') + format)
    if (not serviceRecord.Authorization['Full']):
        fpath = ('/' + fname)
    else:
        fpath = ((serviceRecord.Config['SyncRoot'] + '/') + fname)
    try:
        metadata = dbcl.put_file(fpath, data.encode('UTF-8'))
    except rest.ErrorResponse as e:
        self._raiseDbException(e)
    cache = cachedb.dropbox_cache.find_one({
        'ExternalID': serviceRecord.ExternalID,
    })
    cache['Activities'][self._hash_path(('/' + fname))] = {
        'Rev': metadata['rev'],
        'UID': activity.UID,
        'StartTime': activity.StartTime.strftime('%H:%M:%S %d %m %Y %z'),
        'EndTime': activity.EndTime.strftime('%H:%M:%S %d %m %Y %z'),
    }
    cachedb.dropbox_cache.update({
        'ExternalID': serviceRecord.ExternalID,
    }, cache)
    return fpath

dataset/ETHPy150Open cpfair/tapiriik/tapiriik/services/Dropbox/dropbox.py DropboxService.UploadActivity/VarMisuse@38/52 `activity`->`fpath`