Upload a new molgenis logo
191495
@PreAuthorize("hasAnyRole('ROLE_SU')")
  @PostMapping("/upload-logo")
  public String uploadLogo(@RequestParam("logo") Part part, Model model) throws IOException {
    String contentType = part.getContentType();
    if ((contentType == null) || !contentType.startsWith("image")) {
      model.addAttribute("errorMessage", ERRORMESSAGE_LOGO);
    } else {
      // Create the logo subdir in the filestore if it doesn't exist
      File logoDir = new File(fileStore.getStorageDir() + "/logo");
      if (!logoDir.exists() && !logoDir.mkdir()) {
        throw new IOException("Unable to create directory [" + logoDir.getAbsolutePath() + "]");
      }

      // Store the logo in the logo dir of the filestore
      String file = "/logo/" + FileUploadUtils.getOriginalFileName(part);
      try (InputStream inputStream = part.getInputStream()) {
        fileStore.store(inputStream, file);
      }

      // Set logo
      appSettings.setLogoNavBarHref(file);
    }

    return init(model);
  }
1052272
def update_branding(self, branding_id, params):
        
        connection = Connection(self.token)

        connection.add_header('Content-Type', 'application/json')
        connection.set_url(self.production, self.BRANDINGS_ID_URL % branding_id)
        connection.add_params(params)

        return connection.patch_request()
222847
def _upload_image(registry, docker_tag, image_id) -> None:
    
    # We don't have to retag the image since it is already in the right format
    logging.info('Uploading %s (%s) to %s', docker_tag, image_id, registry)
    push_cmd = ['docker', 'push', docker_tag]
    subprocess.check_call(push_cmd)
717077
function addFavicons() {
  var stream = new Transform({objectMode: true, highWaterMark: 2});

  var hosts = {};
  var downloads = [];
  stream._transform = function (page, _, callback) {
    stream.push(page);
    var host = url.parse(page.url).host;
    if (!hosts[host]) {
      downloads.push(hosts[host] = download(url.resolve(page.url, '/favicon.ico')).then(function (result) {
        if (result.statusCode === 200 &&
            !(result.headers['content-type'] &&
              result.headers['content-type'].indexOf('html') !== -1)) {
          stream.push(result);
        }
      }, function () {
        //ignore errors downloading favicons
      }));
    }
    callback(null);
  };
  stream._flush = function (callback) {
    Promise.all(downloads).done(function () {
      callback();
    }, function (err) {
      stream.emit('error', err);
      callback();
    });
  };
  
  return stream;
}
34300
def _splash():
    """"""
    splash_title = "{pkg} [{version}] - {url}".format(pkg=PKG_NAME,
                                                      version=version, url=PKG_URL)
    log.to_stdout(splash_title, colorf=log.yellow, bold=True)
    log.to_stdout('-' * len(splash_title), colorf=log.yellow, bold=True)
5313
def publish(ctx, test=False):
    """"""
    clean(ctx)
    if test:
        run('python setup.py register -r test sdist bdist_wheel', echo=True)
        run('twine upload dist/* -r test', echo=True)
    else:
        run('python setup.py register sdist bdist_wheel', echo=True)
        run('twine upload dist/*', echo=True)
1351066
def pull_image(self, name, tag='latest'):
        
        name = "{0}/{1}:{2}".format(DOCKER_NEG, name, tag)
        return "/dockerapi/v2/images", dict(image=name)
89728
public function addMetaBoxes()
    {
	// Publish
	add_meta_box(
	    'modularity-mb-publish',
	    __('Save options', 'modularity'),
	    function () {
		$templatePath = \Modularity\Helper\Wp::getTemplate('publish', 'options/partials');
		include $templatePath;
	    },
	    $this->screenHook,
	    'side'
	);

	// Core options
	add_meta_box(
	    'modularity-mb-core-options',
	    __('Core options', 'modularity'),
	    function () {
		$templatePath = \Modularity\Helper\Wp::getTemplate('core-options', 'options/partials');
		include $templatePath;
	    },
	    $this->screenHook,
	    'normal'
	);

	if (has_action('Modularity/Options/Module')) {
	    add_meta_box(
		'modularity-mb-module-options',
		__('Module options', 'modularity'),
		function () {
		    do_action('Modularity/Options/Module');
		},
		$this->screenHook,
		'normal'
	    );
	}

	// Modules
	add_meta_box(
	    'modularity-mb-post-types',
	    __('Post types', 'modularity'),
	    array($this, 'metaBoxPostTypes'),
	    $this->screenHook,
	    'normal'
	);

	// Templates and areas
	add_meta_box(
	    'modularity-mb-template-areas',
	    __('Template areas', 'modularity'),
	    array($this, 'metaBoxTemplateAreas'),
	    $this->screenHook,
	    'normal'
	);

	// Modules
	add_meta_box(
	    'modularity-mb-modules',
	    __('Modules', 'modularity'),
	    array($this, 'metaBoxModules'),
	    $this->screenHook,
	    'normal'
	);
    }
1221234
def _add_goterms_kws(self, go2obj_user, kws_gos):
        """"""
        if 'go2color' in kws_gos:
            for goid in kws_gos['go2color'].keys():
                self._add_goterms(go2obj_user, goid)
493794
def mugshot2to3(old):
    
    new = old.upgradeVersion(Mugshot.typeName, 2, 3,
                             person=old.person,
                             type=old.type,
                             body=old.body,
                             smallerBody=old.smallerBody)
    new.smallerBody = new.makeThumbnail(
        new.body.open(), new.person, new.type[len('image/'):], smaller=True)
    return new
223527
def up(self):
        
        set_interface_up(self.ifIndex, self.auth, self.url, devip=self.ip)
        self.adminstatus = get_interface_details(self.ifIndex, self.auth, self.url, devip=self.ip)[
            'adminStatusDesc']
199300
function (result) {
        if (result.success) {
          var txt = result.create ? 'added' : 'updated'
          console.log('The shield badge has been ' + txt + ' in your ' + that.readmeFilename + ' file')
        } else {
          console.log('Error while adding/updating the shield badge in your ' + that.readmeFilename + ' file: ' + result.error)
        }
      }
698215
def put_object(request, old_pid):
    """"""
    if django.conf.settings.REQUIRE_WHITELIST_FOR_UPDATE:
        d1_gmn.app.auth.assert_create_update_delete_permission(request)
    d1_gmn.app.util.coerce_put_post(request)
    d1_gmn.app.views.assert_db.post_has_mime_parts(
        request, (('field', 'newPid'), ('file', 'object'), ('file', 'sysmeta'))
    )
    d1_gmn.app.views.assert_db.is_valid_pid_to_be_updated(old_pid)
    sysmeta_pyxb = d1_gmn.app.sysmeta.deserialize(request.FILES['sysmeta'])
    new_pid = request.POST['newPid']
    d1_gmn.app.views.assert_sysmeta.matches_url_pid(sysmeta_pyxb, new_pid)
    d1_gmn.app.views.assert_sysmeta.obsoletes_matches_pid_if_specified(
        sysmeta_pyxb, old_pid
    )
    sysmeta_pyxb.obsoletes = old_pid
    sid = d1_common.xml.get_opt_val(sysmeta_pyxb, 'seriesId')
    d1_gmn.app.views.assert_sysmeta.is_valid_sid_for_chain(old_pid, sid)
    d1_gmn.app.views.create.create_sciobj(request, sysmeta_pyxb)
    # The create event for the new object is added in create_sciobj(). The update
    # event on the old object is added here.
    d1_gmn.app.event_log.log_update_event(
        old_pid,
        request,
        timestamp=d1_common.date_time.normalize_datetime_to_utc(
            sysmeta_pyxb.dateUploaded
        ),
    )
    d1_gmn.app.sysmeta.update_modified_timestamp(old_pid)
    return new_pid
1070047
def load_logos(filename):
    '''
    
    '''
    if filename.startswith('http'):
        log.info('Downloading GeoLogos bundle: %s', filename)
        filename, _ = urlretrieve(filename, tmp.path('geologos.tar.xz'))

    log.info('Extracting GeoLogos bundle')
    with contextlib.closing(lzma.LZMAFile(filename)) as xz:
        with tarfile.open(fileobj=xz) as f:
            f.extractall(tmp.root)

    log.info('Moving to the final location and cleaning up')
    if os.path.exists(logos.root):
        shutil.rmtree(logos.root)
    shutil.move(tmp.path('logos'), logos.root)
    log.info('Done')
19327
def upload_napp(self, metadata, package):
        """"""
        endpoint = os.path.join(self._config.get('napps', 'api'), 'napps', '')
        metadata['token'] = self._config.get('auth', 'token')
        request = self.make_request(endpoint, json=metadata, package=package,
                                    method="POST")
        if request.status_code != 201:
            KytosConfig().clear_token()
            LOG.error("%s: %s", request.status_code, request.reason)
            sys.exit(1)

        # WARNING: this will change in future versions, when 'author' will get
        # removed.
        username = metadata.get('username', metadata.get('author'))
        name = metadata.get('name')

        print("SUCCESS: NApp {}/{} uploaded.".format(username, name))
609573
def upload():
    """"""
    build = g.build
    utils.jsonify_assert(len(request.files) == 1,
                         'Need exactly one uploaded file')

    file_storage = request.files.values()[0]
    data = file_storage.read()
    content_type, _ = mimetypes.guess_type(file_storage.filename)

    artifact = _save_artifact(build, data, content_type)

    db.session.add(artifact)
    db.session.commit()

    return flask.jsonify(
        success=True,
        build_id=build.id,
        sha1sum=artifact.id,
        content_type=content_type)
1240345
function createOrUpdateBarRect(bar, symbolMeta, isUpdate) {
    var rectShape = zrUtil.extend({}, symbolMeta.barRectShape);

    var barRect = bar.__pictorialBarRect;
    if (!barRect) {
        barRect = bar.__pictorialBarRect = new graphic.Rect({
            z2: 2,
            shape: rectShape,
            silent: true,
            style: {
                stroke: 'transparent',
                fill: 'transparent',
                lineWidth: 0
            }
        });

        bar.add(barRect);
    }
    else {
        updateAttr(barRect, null, {shape: rectShape}, symbolMeta, isUpdate);
    }
}