Why would shutil.copy() raise a permission exception when cp doesn’t?

The operation that is failing is chmod, not the copy itself: File “/usr/lib/python2.7/shutil.py”, line 91, in copymode os.chmod(dst, mode) OSError: [Errno 1] Operation not permitted: ‘bin/styles/blacktie/images/ajax-loader-000000-e3e3e3.gif’ This indicates that the file already exists and is owned by another user. shutil.copy is specified to copy permission bits. If you only want the file contents to be … Read more

Configure grunt copy task to exclude files/folders

Found the solution: There is no need for these lines: files: [ {src: [‘.conf1’, ‘.conf2’, ‘./config.js’], dest: ‘output/toolkit/’, filter: ‘isFile’}, {src: [‘./css/**/*’, ‘./img/**/*’, ‘./js/**/*’, ‘./release/**/*’, ‘./lib/**/*’, ‘./locale/**/*’], dest: ‘output/toolkit/’}, {expand: true, cwd: ‘./’, src: [‘**’], dest: ‘output/’} ] because {expand: true, cwd: ‘./’, src: [‘**’], dest: ‘output/’} is a new copy step, copying all files … Read more

Docker: Using COPY when the Dockerfile is located in a subdirectory

All you need to do here is add context: . and dockerfile in your build section inside your docker-compose.yml file so that your service understands the complete directory structure. # docker-compose.yml version: “3” services: webserver: build: context: . dockerfile: ./dockerfiles/webserver/Dockerfile image: webserver:php-apache

How to copy a “Dictionary” in Swift?

A ‘Dictionary’ is actually a Struct in swift, which is a value type. So copying it is as easy as: let myDictionary = … let copyOfMyDictionary = myDictionary To copy an object (which is a reference type) has a couple of different answers. If the object adopts the NSCopying protocol, then you can just do: … Read more

How to copy/clone a hash/object in JQuery?

Yes, extend an empty object with the original one; that way, everything will simply be copied: var clone = $.extend({}, settings); Extending some filled object with another, e.g.: $.extend({a:1}, {b:2}) will return: {a:1, b:2} With the same logic: $.extend({}, {foo:’bar’, test:123}) will return: {foo:’bar’, test:123} i.e. effectively a clone.

Maven (Surefire): copy test resources from src/test/java

bmargulies gave the answer, but let me fill in some details. <testresources> can be added to the <build> node of the project’s POM, like this: <testResources> <testResource> <directory>${project.basedir}/src/test/java</directory> </testResource> </testResources> That copies everything in src/test/java — including the .java source code, which we don’t want. It also (as bmargulies only hinted at) overrides and replaces … Read more

memcpy vs for loop – What’s the proper way to copy an array from a pointer?

Yes, the third option is to use a C++ construct: std::copy(&nums[0], &nums[10], myGlobalArray); With any sane compiler, it: should be optimum in the majority of cases (will compile to memcpy() where possible), is type-safe, gracefully copes when you decide to change the data-type to a non-primitive (i.e. it calls copy constructors, etc.), gracefully copes when … Read more