问:
How can I check if a file exists in a tar archive with Python?
I would like to verify the existence of a given file in a tar archive with Python before I get it as a file-like object. I've tried it with isreg(), but probably I do something wrong.

How can I check if a file exists in a tar archive with Python?

I tried

```<code>import tarfile

tar = tarfile.open("sample.tar", "w")
tar.add("test1.txt")
tar.add("test2.txt")
tar.add("test3.py")
tar.close()

tar = tarfile.open("sample.tar", "r")
tai = tar.tarinfo(name="test3.py")
print(tai.isreg())
print(tai.size())
tar.close()
</code>```

Probably tai is wrong. In fact tai.size() is always 0.

答:
This matches even if the tar file has the filename in a subdirectory, and uses normcase to mimic the filename case handling of the current OS (e.g. on Windows, searching for “readme.txt” should match “README.TXT” inside the tar file).</p>

```<code>def filename_in_tar(filename, atarfile):
    filename= os.path.normcase(filename)
    return any(
        filename == os.path.normcase(os.path.basename(tfn))
        for tfn in atarfile.getnames())
</code>```

Body:
I would like to verify the existence of a given file in a tar archive with Python before I get it as a file-like object. I've tried it with isreg(), but probably I do something wrong.

How can I check if a file exists in a tar archive with Python?

I tried

import tarfile

tar = tarfile.open("sample.tar", "w")
tar.add("test1.txt")
tar.add("test2.txt")
tar.add("test3.py")
tar.close()

tar = tarfile.open("sample.tar", "r")
tai = tar.tarinfo(name="test3.py")
print(tai.isreg())
print(tai.size())
tar.close()

Probably tai is wrong. In fact tai.size() is always 0.

Body:
This matches even if the tar file has the filename in a subdirectory, and uses normcase to mimic the filename case handling of the current OS (e.g. on Windows, searching for “readme.txt” should match “README.TXT” inside the tar file).

def filename_in_tar(filename, atarfile):
    filename= os.path.normcase(filename)
    return any(
        filename == os.path.normcase(os.path.basename(tfn))
        for tfn in atarfile.getnames())


来源: stackexchange

问:
Scala Polymorphic Function That Would Compile But Would Not Run As Expected
Given following two Scala functions, both compiles as expected.

```<code>scala> def toList[A](a: A) = List(a)
toList: [A](a: A)List[A]

scala> def foo[A](f: A => List[A], b: A) = f(b)
foo: [A](f: A => List[A], b: A)List[A]
</code>```

Yet, when you run it, it gave following error message:

```<code>scala> foo(toList, 12)
<console>:14: error: type mismatch;
 found   : Nothing => List[Nothing]
 required: Int => List[Int]
       foo(toList, 12)
</code>```

Why does Scala think toList function is of Nothing => List[Nothing] instead of Int => List[Int]?

答:
According how foo is defined, foo(12, toList) is wrong in passing the arguments. Correct way is foo(toList, 12)

Why does Scala think toList function is of Nothing => List[Nothing] instead of Int => List[Int]?

12 is of Int type and since foo is

```<code>def foo[A](f: A => List[A], b: A) = f(b)
</code>```

its expecting A type which is Int for the toList function as well.

If you call foo as foo(toList, 12D) we get following error

```<code><console>:22: error: type mismatch;
 found   : Nothing => List[Nothing]
 required: Double => List[Double]
       foo(toList, 12D)
</code>```

Its because 12D is Double type and toList is expected to be of Double too.

So the correct way would be

```<code>foo(toList[Any], 12)
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Given following two Scala functions, both compiles as expected.

scala> def toList[A](a: A) = List(a)
toList: [A](a: A)List[A]

scala> def foo[A](f: A => List[A], b: A) = f(b)
foo: [A](f: A => List[A], b: A)List[A]

Yet, when you run it, it gave following error message:

scala> foo(toList, 12)
<console>:14: error: type mismatch;
 found   : Nothing => List[Nothing]
 required: Int => List[Int]
       foo(toList, 12)

Why does Scala think toList function is of Nothing => List[Nothing] instead of Int => List[Int]?

Body:
According how foo is defined, foo(12, toList) is wrong in passing the arguments. Correct way is foo(toList, 12)

Why does Scala think toList function is of Nothing => List[Nothing] instead of Int => List[Int]?

12 is of Int type and since foo is

def foo[A](f: A => List[A], b: A) = f(b)

its expecting A type which is Int for the toList function as well.

If you call foo as foo(toList, 12D) we get following error

<console>:22: error: type mismatch;
 found   : Nothing => List[Nothing]
 required: Double => List[Double]
       foo(toList, 12D)

Its because 12D is Double type and toList is expected to be of Double too.

So the correct way would be

foo(toList[Any], 12)


问:
Which SSIS System Variable holds error text
I am running a SSIS package using SQL Server 2008 Job. The package crash at some point while running. I have created my own mechanism to grab the error and record it in a table. So I can see that there is an error with an specific task, but could not find what the error is.

When I run the same package from BIDS, it works perfect. no error.

What I want to do is, I need to write that error string to my own table which shown in the "Execution Result" tab.

So the question is which system variable holds the error string in SSIS.

答: Check this out! He has explained with a Step by step process on how to configure SSIS logging which has the error message parameter.</p>


问:
Error:Could not download artifact 'com.android.tools.build:gradle:0.13.2:gradle.jar': No cached version available for offline mode
I use macos.
when i update android studio it ask move the sdk from application to other.
i has move and update successfully.
but now the above error come:--

Error:Could not download artifact 'com.android.tools.build:gradle:0.13.2:gradle.jar': No cached version available for offline mode.

i download new android studio but it come same error without uninstall old IDE because it in some project have.

please help me.

this error will come in idea.log file

```2014-11-07 18:47:05,746 [ 602060]   INFO -                  TestNG Runner - Create TestNG Template Configuration
2014-11-07 18:47:05,746 [ 602060]   INFO -                  TestNG Runner - Create TestNG Template Configuration
2014-11-07 18:47:05,756 [ 602070]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/dynamic.xml file is null
2014-11-07 18:47:05,770 [ 602084]   INFO - ellij.project.impl.ProjectImpl - 139 project components initialized in 70 ms
2014-11-07 18:47:05,774 [ 602088]   INFO - le.impl.ModuleManagerComponent - 1 module(s) loaded in 4 ms
2014-11-07 18:47:05,789 [ 602103]   WARN - j.ui.mac.MacMainFrameDecorator - no url bundle present.
To use platform protocol handler to open external links specify required protocols in the mac app layout section of the build file
Example: args.urlSchemes = ["your-protocol"] will handle following links: your-protocol://open?file=file&line=line
2014-11-07 18:47:05,995 [ 602309]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
2014-11-07 18:47:05,996 [ 602310]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
2014-11-07 18:47:06,026 [ 602340]   INFO - .project.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: [-Pandroid.injected.build.model.only=true, -Pandroid.injected.invoked.from.ide=true, --init-script, /private/var/folders/py/t8f3wlmj7694zcrwq7t661pc0000gp/T/ijinit9125299397050185635.gradle, --offline]
2014-11-07 18:47:06,077 [ 602391]   INFO - .roots.impl.DirectoryIndexImpl - Directory index initialized in 0 ms, indexed 0 directories
2014-11-07 18:47:06,078 [ 602392]   INFO - pl.PushedFilePropertiesUpdater - File properties pushed in 1 ms
2014-11-07 18:47:06,092 [ 602406]   INFO - indexing.UnindexedFilesUpdater - Indexable files iterated in 3 ms
2014-11-07 18:47:06,093 [ 602407]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 0 files to update
2014-11-07 18:47:06,093 [ 602407]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update done in 0 ms
2014-11-07 18:47:06,407 [ 602721]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/codeStyleSettings.xml file is null
2014-11-07 18:47:06,408 [ 602722]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/projectCodeStyle.xml file is null
2014-11-07 18:47:06,431 [ 602745]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/fileColors.xml file is null
2014-11-07 18:47:06,782 [ 603096]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/gant_config.xml file is null
2014-11-07 18:47:06,797 [ 603111]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/IntelliLang.xml file is null
2014-11-07 18:47:07,016 [ 603330]   INFO - .project.GradleProjectResolver - Gradle project resolve error
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.1-all.zip'.
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:53)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
    at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter.run(DefaultBuildActionExecuter.java:43)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:186)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$300(GradleProjectResolver.java:64)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:361)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:333)
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:203)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:116)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:64)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:406)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3$2.run(ExternalSystemUtil.java:483)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:471)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:380)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:419)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:149)
Caused by: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'DeltestApplication'.
    at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:77)
    at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
    at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108)
    at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:97)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.configure(InProcessBuildActionExecuter.java:84)
    at org.gradle.tooling.internal.provider.ClientProvidedBuildAction.run(ClientProvidedBuildAction.java:49)
    at org.gradle.tooling.internal.provider.ClientProvidedBuildAction.run(ClientProvidedBuildAction.java:31)
    at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:134)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:35)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:70)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:258)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.HandleCancel.execute(HandleCancel.java:36)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:30)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:52)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:154)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'DeltestApplication'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:57)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:521)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:82)
    at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    ... 47 more
Caused by: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':classpath'.
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.wrapException(ErrorHandlingArtifactDependencyResolver.java:61)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.access$000(ErrorHandlingArtifactDependencyResolver.java:35)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver$ErrorHandlingResolvedConfiguration.getFiles(ErrorHandlingArtifactDependencyResolver.java:190)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:430)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:202)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getFiles(Unknown Source)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:171)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
    at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
    ... 52 more
Caused by: org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ArtifactResolveException: Could not download artifact 'com.android.tools.build:gradle:0.13.2:gradle.jar': No cached version available for offline mode
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.StartParameterResolutionOverride$FailedRemoteAccess.resolveArtifact(StartParameterResolutionOverride.java:115)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository$ResolveAndCacheRepositoryAccess.resolveArtifact(CachingModuleComponentRepository.java:325)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.BaseModuleComponentRepositoryAccess.resolveArtifact(BaseModuleComponentRepositoryAccess.java:49)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedModuleComponentRepository$CachedAccess.resolveArtifact(InMemoryCachedModuleComponentRepository.java:74)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainArtifactResolver.resolveArtifact(RepositoryChainArtifactResolver.java:61)
    at org.gradle.api.internal.artifacts.ivyservice.projectmodule.ProjectArtifactResolver.resolveArtifact(ProjectArtifactResolver.java:62)
    at org.gradle.api.internal.artifacts.ivyservice.ContextualArtifactResolver$3.execute(ContextualArtifactResolver.java:55)
    at org.gradle.api.internal.artifacts.ivyservice.ContextualArtifactResolver$3.execute(ContextualArtifactResolver.java:53)
    at org.gradle.internal.Transformers$3.transform(Transformers.java:131)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:61)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:39)
    at org.gradle.api.internal.artifacts.ivyservice.ContextualArtifactResolver$4.run(ContextualArtifactResolver.java:63)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:187)
    at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175)
    at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106)
    at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:64)
    at org.gradle.api.internal.artifacts.ivyservice.ContextualArtifactResolver.executeInContext(ContextualArtifactResolver.java:61)
    at org.gradle.api.internal.artifacts.ivyservice.ContextualArtifactResolver.resolveArtifact(ContextualArtifactResolver.java:53)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingArtifactResolver.resolveArtifact(ErrorHandlingArtifactResolver.java:48)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.DefaultResolvedConfigurationBuilder$LazyArtifactSource.create(DefaultResolvedConfigurationBuilder.java:129)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.DefaultResolvedConfigurationBuilder$LazyArtifactSource.create(DefaultResolvedConfigurationBuilder.java:116)
    at org.gradle.api.internal.artifacts.DefaultResolvedArtifact.getFile(DefaultResolvedArtifact.java:93)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$2.run(DefaultLenientConfiguration.java:112)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:187)
    at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175)
    at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106)
    at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:64)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.getFiles(DefaultLenientConfiguration.java:109)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.getFilesStrict(DefaultLenientConfiguration.java:81)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultResolvedConfiguration.getFiles(DefaultResolvedConfiguration.java:45)
    at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver$FilesAggregatingResolvedConfiguration.getFiles(SelfResolvingDependencyResolver.java:85)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver$ErrorHandlingResolvedConfiguration.getFiles(ErrorHandlingArtifactDependencyResolver.java:188)
    ... 60 more
2014-11-07 18:47:07,020 [ 603334]   INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at '/Users/devsysuit/AndroidStudioProjects/DeltestApplication'
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.1-all.zip'.
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:53)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
    at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter.run(DefaultBuildActionExecuter.java:43)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:186)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$300(GradleProjectResolver.java:64)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:361)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:333)
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:203)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:116)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:64)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:406)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3$2.run(ExternalSystemUtil.java:483)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:471)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:380)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:419)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:149)
Caused by: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'DeltestApplication'.
    at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:77)
    at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
    at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108)
    at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:97)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.configure(InProcessBuildActionExecuter.java:84)
    at org.gradle.tooling.internal.provider.ClientProvidedBuildAction.run(ClientProvidedBuildAction.java:49)
    at org.gradle.tooling.internal.provider.ClientProvidedBuildAction.run(ClientProvidedBuildAction.java:31)
    at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:134)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47)
    at
    at
```

答:
Change your classpath gradle version in your project gradle to:</p>

```<code>classpath 'com.android.tools.build:gradle:2.2.0'
</code>```

Body:
I use macos.
when i update android studio it ask move the sdk from application to other.
i has move and update successfully.
but now the above error come:--

Error:Could not download artifact 'com.android.tools.build:gradle:0.13.2:gradle.jar': No cached version available for offline mode.

i download new android studio but it come same error without uninstall old IDE because it in some project have.

please help me.

this error will come in idea.log file

2014-11-07 18:47:05,746 [ 602060]   INFO -                  TestNG Runner - Create TestNG Template Configuration
2014-11-07 18:47:05,746 [ 602060]   INFO -                  TestNG Runner - Create TestNG Template Configuration
2014-11-07 18:47:05,756 [ 602070]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/dynamic.xml file is null
2014-11-07 18:47:05,770 [ 602084]   INFO - ellij.project.impl.ProjectImpl - 139 project components initialized in 70 ms
2014-11-07 18:47:05,774 [ 602088]   INFO - le.impl.ModuleManagerComponent - 1 module(s) loaded in 4 ms
2014-11-07 18:47:05,789 [ 602103]   WARN - j.ui.mac.MacMainFrameDecorator - no url bundle present.
To use platform protocol handler to open external links specify required protocols in the mac app layout section of the build file
Example: args.urlSchemes = ["your-protocol"] will handle following links: your-protocol://open?file=file&line=line
2014-11-07 18:47:05,995 [ 602309]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
2014-11-07 18:47:05,996 [ 602310]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
2014-11-07 18:47:06,026 [ 602340]   INFO - .project.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: [-Pandroid.injected.build.model.only=true, -Pandroid.injected.invoked.from.ide=true, --init-script, /private/var/folders/py/t8f3wlmj7694zcrwq7t661pc0000gp/T/ijinit9125299397050185635.gradle, --offline]
2014-11-07 18:47:06,077 [ 602391]   INFO - .roots.impl.DirectoryIndexImpl - Directory index initialized in 0 ms, indexed 0 directories
2014-11-07 18:47:06,078 [ 602392]   INFO - pl.PushedFilePropertiesUpdater - File properties pushed in 1 ms
2014-11-07 18:47:06,092 [ 602406]   INFO - indexing.UnindexedFilesUpdater - Indexable files iterated in 3 ms
2014-11-07 18:47:06,093 [ 602407]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 0 files to update
2014-11-07 18:47:06,093 [ 602407]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update done in 0 ms
2014-11-07 18:47:06,407 [ 602721]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/codeStyleSettings.xml file is null
2014-11-07 18:47:06,408 [ 602722]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/projectCodeStyle.xml file is null
2014-11-07 18:47:06,431 [ 602745]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/fileColors.xml file is null
2014-11-07 18:47:06,782 [ 603096]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/gant_config.xml file is null
2014-11-07 18:47:06,797 [ 603111]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/IntelliLang.xml file is null
2014-11-07 18:47:07,016 [ 603330]   INFO - .project.GradleProjectResolver - Gradle project resolve error
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.1-all.zip'.
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:53)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
    at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter.run(DefaultBuildActionExecuter.java:43)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:186)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$300(GradleProjectResolver.java:64)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:361)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:333)
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:203)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:116)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:64)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:406)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3$2.run(ExternalSystemUtil.java:483)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:471)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:380)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:419)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:149)
Caused by: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'DeltestApplication'.
    at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:77)
    at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
    at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108)
    at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:97)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.configure(InProcessBuildActionExecuter.java:84)
    at org.gradle.tooling.internal.provider.ClientProvidedBuildAction.run(ClientProvidedBuildAction.java:49)
    at org.gradle.tooling.internal.provider.ClientProvidedBuildAction.run(ClientProvidedBuildAction.java:31)
    at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:134)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:35)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:70)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:258)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.HandleCancel.execute(HandleCancel.java:36)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:30)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:52)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:154)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'DeltestApplication'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:57)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:521)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:82)
    at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    ... 47 more
Caused by: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':classpath'.
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.wrapException(ErrorHandlingArtifactDependencyResolver.java:61)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.access$000(ErrorHandlingArtifactDependencyResolver.java:35)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver$ErrorHandlingResolvedConfiguration.getFiles(ErrorHandlingArtifactDependencyResolver.java:190)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:430)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:202)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getFiles(Unknown Source)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:171)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
    at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
    ... 52 more
Caused by: org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ArtifactResolveException: Could not download artifact 'com.android.tools.build:gradle:0.13.2:gradle.jar': No cached version available for offline mode
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.StartParameterResolutionOverride$FailedRemoteAccess.resolveArtifact(StartParameterResolutionOverride.java:115)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository$ResolveAndCacheRepositoryAccess.resolveArtifact(CachingModuleComponentRepository.java:325)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.BaseModuleComponentRepositoryAccess.resolveArtifact(BaseModuleComponentRepositoryAccess.java:49)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedModuleComponentRepository$CachedAccess.resolveArtifact(InMemoryCachedModuleComponentRepository.java:74)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainArtifactResolver.resolveArtifact(RepositoryChainArtifactResolver.java:61)
    at org.gradle.api.internal.artifacts.ivyservice.projectmodule.ProjectArtifactResolver.resolveArtifact(ProjectArtifactResolver.java:62)
    at org.gradle.api.internal.artifacts.ivyservice.ContextualArtifactResolver$3.execute(ContextualArtifactResolver.java:55)
    at org.gradle.api.internal.artifacts.ivyservice.ContextualArtifactResolver$3.execute(ContextualArtifactResolver.java:53)
    at org.gradle.internal.Transformers$3.transform(Transformers.java:131)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:61)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:39)
    at org.gradle.api.internal.artifacts.ivyservice.ContextualArtifactResolver$4.run(ContextualArtifactResolver.java:63)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:187)
    at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175)
    at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106)
    at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:64)
    at org.gradle.api.internal.artifacts.ivyservice.ContextualArtifactResolver.executeInContext(ContextualArtifactResolver.java:61)
    at org.gradle.api.internal.artifacts.ivyservice.ContextualArtifactResolver.resolveArtifact(ContextualArtifactResolver.java:53)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingArtifactResolver.resolveArtifact(ErrorHandlingArtifactResolver.java:48)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.DefaultResolvedConfigurationBuilder$LazyArtifactSource.create(DefaultResolvedConfigurationBuilder.java:129)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.DefaultResolvedConfigurationBuilder$LazyArtifactSource.create(DefaultResolvedConfigurationBuilder.java:116)
    at org.gradle.api.internal.artifacts.DefaultResolvedArtifact.getFile(DefaultResolvedArtifact.java:93)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$2.run(DefaultLenientConfiguration.java:112)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:187)
    at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175)
    at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106)
    at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:64)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.getFiles(DefaultLenientConfiguration.java:109)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.getFilesStrict(DefaultLenientConfiguration.java:81)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultResolvedConfiguration.getFiles(DefaultResolvedConfiguration.java:45)
    at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver$FilesAggregatingResolvedConfiguration.getFiles(SelfResolvingDependencyResolver.java:85)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver$ErrorHandlingResolvedConfiguration.getFiles(ErrorHandlingArtifactDependencyResolver.java:188)
    ... 60 more
2014-11-07 18:47:07,020 [ 603334]   INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at '/Users/devsysuit/AndroidStudioProjects/DeltestApplication'
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.1-all.zip'.
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:53)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
    at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter.run(DefaultBuildActionExecuter.java:43)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:186)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$300(GradleProjectResolver.java:64)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:361)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:333)
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:203)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:116)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:64)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:406)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3$2.run(ExternalSystemUtil.java:483)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:471)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:380)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:419)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:149)
Caused by: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'DeltestApplication'.
    at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:77)
    at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
    at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108)
    at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:97)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.configure(InProcessBuildActionExecuter.java:84)
    at org.gradle.tooling.internal.provider.ClientProvidedBuildAction.run(ClientProvidedBuildAction.java:49)
    at org.gradle.tooling.internal.provider.ClientProvidedBuildAction.run(ClientProvidedBuildAction.java:31)
    at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:134)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47)
    at
    at

Body:
Change your classpath gradle version in your project gradle to:

classpath 'com.android.tools.build:gradle:2.2.0'


问:
How to get a button element made in the DOM, run a function
I created a button element using javascript, and now would like to know how to find that element or select it and get it to call this function:</p>

```<code>    function test() {
      alert("it works!");
    }
</code>```

答:
Have a look at below snippet.

var bIsCreated = false;
$(document).ready(function() {
  $("#createNewButton").on("click", createNewButton);
  $(document).on("click", ".newButton", function() {
    alert("I am a new button");
  });
});

function createNewButton() {
  if (!bIsCreated) {
    var $newButton = $("<button/>").addClass("newButton")
      .html("I am a new button");
    $newButton.appendTo(".container");
  }
  alert("I am a old button");
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="container">
  <button id="createNewButton"> Create a new button</button>
</div></code>```

Body:
I created a button element using javascript, and now would like to know how to find that element or select it and get it to call this function:

    function test() {
      alert("it works!");
    }

Body:
Have a look at below snippet.

var bIsCreated = false;
$(document).ready(function() {
  $("#createNewButton").on("click", createNewButton);
  $(document).on("click", ".newButton", function() {
    alert("I am a new button");
  });
});

function createNewButton() {
  if (!bIsCreated) {
    var $newButton = $("<button/>").addClass("newButton")
      .html("I am a new button");
    $newButton.appendTo(".container");
  }
  alert("I am a old button");
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="container">
  <button id="createNewButton"> Create a new button</button>
</div>


问:
Replace nth and (n+1)th values in one file with same values from another file
i have two files:

f1.txt:

```<code>header 1
header 2
100
100
100
100
100
100
100
100
100
100
100
100
100
</code>```

f2.txt:

```<code>header 1
header 2
10
1234
5678
10
10
2345
6789
10
10
3456
7890
10
10
</code>```

desired output

f3.txt:

```<code>header 1
header 2
100
1234
5678
100
100
2345
6789
100
100
3456
7890
100
100
</code>```

the values in f2.txt that occur in lines 4 & 5, then 8 & 9, then 12 & 13 (i.e., they're spaced every 6th row), i want to put them inside f1.txt to replace the corresponding rows in f1.txt. how can i do this?

so far, i have only been able to print these values out of f2.txt as such:

```<code>exec<f2.txt
var=$(awk 'NR % 6 == 4')
echo "$var"
</code>```

this produces

```<code>1234
2345
3456
</code>```

then when i change 4 to 5, it gives me the 2nd set of values. so am trying to learn how to extract the 2 sets of values, and then put them in f1.txt? any help will be greatly appreciated.  thanks!

答:
Try:

```<code>paste f1.txt f2.txt | awk -F'\t' '
    NR < 3 || (NR-2)%4 == 1 || (NR-2)%4 == 0 {print $1; next}
    {print $2}
'
</code>```

Your desired output does not indicate groups of 6 lines, but instead groups of 4 lines. Perhaps the 2 header lines are throwing you off.

I'm assuming your input files do not contain tabs.

More concise awk from Ed Morton:

```<code>awk -F'\t' '{print (NR-2)%4 < 2 ? $1 : $2}'
</code>```

Body:
i have two files:

f1.txt:

header 1
header 2
100
100
100
100
100
100
100
100
100
100
100
100
100

f2.txt:

header 1
header 2
10
1234
5678
10
10
2345
6789
10
10
3456
7890
10
10

desired output

f3.txt:

header 1
header 2
100
1234
5678
100
100
2345
6789
100
100
3456
7890
100
100

the values in f2.txt that occur in lines 4 & 5, then 8 & 9, then 12 & 13 (i.e., they're spaced every 6th row), i want to put them inside f1.txt to replace the corresponding rows in f1.txt. how can i do this?

so far, i have only been able to print these values out of f2.txt as such:

exec<f2.txt
var=$(awk 'NR % 6 == 4')
echo "$var"

this produces

1234
2345
3456

then when i change 4 to 5, it gives me the 2nd set of values. so am trying to learn how to extract the 2 sets of values, and then put them in f1.txt? any help will be greatly appreciated.  thanks!

Body:
Try:

paste f1.txt f2.txt | awk -F'\t' '
    NR < 3 || (NR-2)%4 == 1 || (NR-2)%4 == 0 {print $1; next}
    {print $2}
'

Your desired output does not indicate groups of 6 lines, but instead groups of 4 lines. Perhaps the 2 header lines are throwing you off.

I'm assuming your input files do not contain tabs.

More concise awk from Ed Morton:

awk -F'\t' '{print (NR-2)%4 < 2 ? $1 : $2}'


问:
Running oozie in local mode gives error
I am trying to run a oozie job using below xml . However the action fails with the error:

Main class [org.apache.oozie.action.hadoop.SparkMain], exit code [101]

On Analysis of logs I observed that error was because of java.lang.ClassNotFoundException: Mainclass. However Mainclass exists in jar in hdfs location. The jar is specified in  in xml below.Here is my code:

```<code><action name="action1" cred="hive_credentials">
                <spark xmlns="uri:oozie:spark-action:0.2">
                        <job-tracker>${jobTracker}</job-tracker>
                        <name-node>${nameNode}</name-node>
                        <master>local[*]</master>
                        <name>name</name>
                        <class>Mainclass</class>
                        <jar>${jar1}</jar>
                        <spark-opts>
                                --files hive-site.xml --conf spark.yarn.security.tokens.hive.enabled=false
                        </spark-opts>
                        <arg>arg1</arg>
                        <file>${nameNode}/test/${wf:user()}/hive-site.xml</file>
                </spark>
                <ok to="end" />
                <error to="kill_job" />
        </action>
</code>```

What could be the issue?

答:
I resolved the issue,

1) Creating a "lib" folder directly next to workflow xml

2) Copying Mainclass jar to lib folder

3) Specifying only jar name in  tag and not fully qualified hdfs path

Title: Running oozie in local mode gives error

Body:
I am trying to run a oozie job using below xml . However the action fails with the error:

Main class [org.apache.oozie.action.hadoop.SparkMain], exit code [101]

On Analysis of logs I observed that error was because of java.lang.ClassNotFoundException: Mainclass. However Mainclass exists in jar in hdfs location. The jar is specified in  in xml below.Here is my code:

<action name="action1" cred="hive_credentials">
                <spark xmlns="uri:oozie:spark-action:0.2">
                        <job-tracker>${jobTracker}</job-tracker>
                        <name-node>${nameNode}</name-node>
                        <master>local[*]</master>
                        <name>name</name>
                        <class>Mainclass</class>
                        <jar>${jar1}</jar>
                        <spark-opts>
                                --files hive-site.xml --conf spark.yarn.security.tokens.hive.enabled=false
                        </spark-opts>
                        <arg>arg1</arg>
                        <file>${nameNode}/test/${wf:user()}/hive-site.xml</file>
                </spark>
                <ok to="end" />
                <error to="kill_job" />
        </action>

What could be the issue?


问:
Drop R data.frame columns based on Row Value
I have a dataFrame setup like this:

```<code>dfRiskChanges <<- data.frame(-1, -1, -1, -1, -1, -1, -1, -1)
colnames(dfRiskChanges) <<- c('Funcational', 'Steroid', 'HxCHF', 'SOB',
                            'HxCOPD', 'Smoker', 'DMAll', 'HTNMed')
</code>```

Then I replace the applicable dataFrame values with real numbers, so a final version of the dataFrame could be:

```<code>Funcational Steroid HxCHF SOB HxCOPD   Smoker    DMAll        HTNMed
-1          -1      -1     -1   -1        -1        1.983131    -1 0.6438011
</code>```

Now I want to drop all the columns where the value is -1.

I've been trying things like this:

```<code>dfRiskChanges.new <- dfRiskChanges[dfRiskChanges$units != -1, ]
</code>```

and

```<code>dfRiskChanges.new <<- dfRiskChanges %>% filter(units != -1)
</code>```

and

```<code>dfRiskChanges %>% select_if(function(col) all(col != -1))
</code>```

All without success. Any help would be appreciated!

答:
Using the select_if function from dplyr, I modified your code a little bit as follows.

```<code>dfRiskChanges <- data.frame(
  'Funcational' = -1,
  'Steroid' = -1,
  'HxCHF' = -1,
  'SOB' = -1,
  'HxCOPD' = -1,
  'Smoker' = 1.983131,
  'DMAll' = -1,
  'HTNMed' = 0.6438011
  )

library(dplyr)
dfRiskChanges %>% select_if(function(col) sum(col) != -1)
</code>```

Body:
I have a dataFrame setup like this:

dfRiskChanges <<- data.frame(-1, -1, -1, -1, -1, -1, -1, -1)
colnames(dfRiskChanges) <<- c('Funcational', 'Steroid', 'HxCHF', 'SOB',
                            'HxCOPD', 'Smoker', 'DMAll', 'HTNMed')

Then I replace the applicable dataFrame values with real numbers, so a final version of the dataFrame could be:

Funcational Steroid HxCHF SOB HxCOPD   Smoker    DMAll        HTNMed
-1          -1      -1     -1   -1        -1        1.983131    -1 0.6438011

Now I want to drop all the columns where the value is -1.

I've been trying things like this:

dfRiskChanges.new <- dfRiskChanges[dfRiskChanges$units != -1, ]

and

dfRiskChanges.new <<- dfRiskChanges %>% filter(units != -1)

and

dfRiskChanges %>% select_if(function(col) all(col != -1))

All without success. Any help would be appreciated!

Body:
Using the select_if function from dplyr, I modified your code a little bit as follows.

dfRiskChanges <- data.frame(
  'Funcational' = -1,
  'Steroid' = -1,
  'HxCHF' = -1,
  'SOB' = -1,
  'HxCOPD' = -1,
  'Smoker' = 1.983131,
  'DMAll' = -1,
  'HTNMed' = 0.6438011
  )

library(dplyr)
dfRiskChanges %>% select_if(function(col) sum(col) != -1)


问:
Simulate touch command with Java
I want to change modification timestamp of a binary file. What is the best way for doing this?

Would opening and closing the file be a good option? (I require a solution where the modification of the timestamp will be changed on every platform and JVM).

答:
Since File is a bad abstraction, it is better to use Files and Path:

```<code>public static void touch(final Path path) throws IOException {
    Objects.requireNonNull(path, "path is null");
    try {
        Files.createFile(path);
    } catch (FileAlreadyExistsException e) {
        Files.setLastModifiedTime(path, FileTime.from(Instant.now()));
    }
}
</code>```

ContentLicense: CC BY-SA 2.5

Title: Simulate touch command with Java

Body:
Since File is a bad abstraction, it is better to use Files and Path:

public static void touch(final Path path) throws IOException {
    Objects.requireNonNull(path, "path is null");
    try {
        Files.createFile(path);
    } catch (FileAlreadyExistsException e) {
        Files.setLastModifiedTime(path, FileTime.from(Instant.now()));
    }
}

ContentLicense: CC BY-SA 4.0


问:
Tab Order in Visual Studio hates me
Tab Order in Visual Studio does not work for me for some reason.

I am making a VB.NET plugin for a cad program called Rhinocreos 5.

I have everything set perfect, and I don't know what the cause of it is.

I am using .Show() instead of .ShowDialog(), because I need that thread open and I don't feel like doing any thread management (not paid enough lol)

Does anyone have any pointers for this? Has anyone else ran into a tab problem with Rhino5 and .NET?

EDIT**
Seems I have to use a MODELESS Form for a rhino plugin.... So I wont have any tab keys or arrow keys unless I do a hook. But since I need to make the plugin future proof (in case I am no longer working here), I won't be doing that either. But thanks for the answers, comments, and awesome downvotes.

答:
It was a modeless form inside of Rhino3D as a plugin.

Rhino3D uses all plugins in the main thread. So tab is not an option.

The workaround was to tag all controls with a tag work (I used "tabMe")

Then I store all the controls in a List myTabbyControls.

Each time I press tab, I would cycle through the list.

But thanks for the down votes. It's the running joke of SO.

Title: Tab Order in Visual Studio hates me


问:
Is WCF ready for real world?
As I read here http://arunatennakoon.blogspot.com/2010/11/things-i-learn-new-this-week.html

```<code>Friday, November 12, 2010
Things I learn new this week
1. Never ever use WCF.
---------------------

here is why
1. IIS 7 doesn't support .svc file format by default. So you need to
</code>```

install some extension files. so it's
  lot of work for a new product.

```<code>2. I found it very hard to configure security settings. when i
</code>```

tried to configure for the first time
  it threw all kind of errors.

```<code>3. After installing WCF in IIS, sometimes it's trowing an exception
</code>```

that refers to the temp directory. To
  solve this problem you have to re
  compile the application and
  re-distribute

```<code>and a lot more...
</code>```

So would you take the risk to use WCF ?

I'd like to hear about real world examples with hundred to billions of hit per year.

答:
WCF is definitely ready for the real world. Yes sometimes it is overkill so first you have to know if you really need it. If you need WS-* protocol stack or if you need web services interoperability with non MS platform you will need WCF. I'm using WCF regulary and I'm very happy with it.

IMO WCF is third best API MS provided (.NET Core is first, ASP.NET MVC second). It has so many extensibility points that you can do almost anything. But it is not easy. WCF is for mature skilled developers - it's the main WCF drawback.

Reasons mentioned in article are silly. It is like saying that ASP.NET 4.0 is not ready for the real world because sometimes you have to run aspnet_regiis.exe to register .NET 4.0 runtime in IIS or like saying that Lambda expressions are not ready for the real world because you have to learn how to use them.

Title: Is WCF ready for real world?

Body:
As I read here http://arunatennakoon.blogspot.com/2010/11/things-i-learn-new-this-week.html

Friday, November 12, 2010
Things I learn new this week
1. Never ever use WCF.
---------------------

here is why
1. IIS 7 doesn't support .svc file format by default. So you need to

install some extension files. so it's
  lot of work for a new product.

2. I found it very hard to configure security settings. when i

tried to configure for the first time
  it threw all kind of errors.

3. After installing WCF in IIS, sometimes it's trowing an exception

that refers to the temp directory. To
  solve this problem you have to re
  compile the application and
  re-distribute

and a lot more...

So would you take the risk to use WCF ?

I'd like to hear about real world examples with hundred to billions of hit per year.


问:
Prepared Statement Joins in Java
Is it possible to do Joins in java using prepared statements?

```<code>public class Test {

    static Connection conn;
    static PreparedStatement ps;

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        try {

        String sql = "select addr.address_id from address addr inner join pizza_stores ps on addr.address_id = ps.address_id";

        conn = ConnectionUtil.getConnection();
        ps = conn.prepareStatement(sql);
        System.out.println("DEBUG--: before query");
        ResultSet rs = ps.executeQuery(sql);

        while(rs.next()) {
            System.out.println(rs.getInt("addr.address_id"));
        }

        ps.close();
        conn.close();

    } catch (SQLException e) {
        e.printStackTrace();
    }

    }

}
</code>```

I get no results but when I run in sql developer I do get results (ex ADDRESS_ID -> 1, 2 ,3). I will be using stored procedure for this later. I am just curious.

答:
I figured out the problem.

So I had two tables (address and pizza_stores).

When I created the pizza_stores table, in the FK, I referenced it to the pizza_stores table (same table) instead of address table. Therefore it wasn't printing anything.

The java code works it was more of a constraint problem in sql.

Title: Prepared Statement Joins in Java

Body:
Is it possible to do Joins in java using prepared statements?

public class Test {

    static Connection conn;
    static PreparedStatement ps;

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        try {

        String sql = "select addr.address_id from address addr inner join pizza_stores ps on addr.address_id = ps.address_id";

        conn = ConnectionUtil.getConnection();
        ps = conn.prepareStatement(sql);
        System.out.println("DEBUG--: before query");
        ResultSet rs = ps.executeQuery(sql);

        while(rs.next()) {
            System.out.println(rs.getInt("addr.address_id"));
        }

        ps.close();
        conn.close();

    } catch (SQLException e) {
        e.printStackTrace();
    }

    }

}

I get no results but when I run in sql developer I do get results (ex ADDRESS_ID -> 1, 2 ,3). I will be using stored procedure for this later. I am just curious.


问:
Android Studio v7- Import errors for few classes (Cannot resolve symbol)
I am a beginner to Android Programming. I am trying to create a basic Hello World App using Android Studio. I am getting following errors in Java File immediately after following the initial steps to create the Hello World Program.

```<code>"Cannot resolve Symbol FloatingActionButton"
"Cannot resolve Symbol Snackbar"
"Cannot resolve Symbol AppCompatActivity"
"Cannot resolve Symbol Toolbar"
</code>```

As you can see in the attached Image the errors are in red.
Please help me out here.

My build file content:

```<code> defaultConfig {
        applicationId "com.example.helloworld.helloworld"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
}
</code>```

Seems like I have added all the relevant dependencies.

答:
Include compile 'com.android.support:design:25.3.1' in build.gradle(Module:app)

Change the version 25.3.1 to match your compile 'com.android.support:appcompat-v7:25.3.1' dependency

Import import android.support.design.widget.FloatingActionButton; in activity

Body:
I am a beginner to Android Programming. I am trying to create a basic Hello World App using Android Studio. I am getting following errors in Java File immediately after following the initial steps to create the Hello World Program.

"Cannot resolve Symbol FloatingActionButton"
"Cannot resolve Symbol Snackbar"
"Cannot resolve Symbol AppCompatActivity"
"Cannot resolve Symbol Toolbar"

As you can see in the attached Image the errors are in red.
Please help me out here.

My build file content:

 defaultConfig {
        applicationId "com.example.helloworld.helloworld"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
}

Seems like I have added all the relevant dependencies.


问:
Scaling :hover effect isn't working in css on

Short and simple, I'm trying to use a hover effect, and I can't seem to get it to work within this DIV at the moment and I've never came across this problem and I can't find out where I went wrong.

.navbar {
      border: solid 0px; background-color: #E6E6E6; padding-top: 15px; padding-
      bottom: 15px;
      position: absolute; top: 230px; left: 320px;
      font-family: sans-serif;
      }
     .shopping,
     .food,
     .hotels,
     .entertainment,
     .guide {
      display: inline;
      padding-right: 90px;
      padding-left: 90px;
      }
      .shopping:hover,
      .food:hover,
      .hotels:hover,
      .entertainment:hover,
      .guide:hover {
       color: yellow;
       -webkit-transform: scale(1.3);
       -ms-transform: scale(1.3);
       transform: scale(1.3);
       }```
<pre class="snippet-code-html lang-html prettyprint-override"><code> <div class="navbar">
      <p class="shopping">Shopping</p>
      <p class="food">href="food.html">Food</p>
      <p class="hotels">href="hotels.html">Hotels</p>
      <p class="entertainment">href="entertainment.html">Entertainment</p>
      <p class="guide">href="guide.html">The total NOLA guide.</p>
     </div>
     </code>```

The weird part is that the color yellow ends up being shown but the hover that I want the scaling portion is not working and I can't figure it out.

答:
Change your code  to this.It will target the anchor tag inside the p tag.And add display:inline-block to the anchor tag for the scale to work

```<code>    .shopping:hover a,
      .food:hover a,
      .hotels:hover a,
      .entertainment:hover a,
      .guide:hover a{
       color: yellow;
       -webkit-transform: scale(1.3);
       -ms-transform: scale(1.3);
       transform: scale(1.3);
    }
</code>```

.navbar {
      border: solid 0px; background-color: #E6E6E6; padding-top: 15px; padding-
      bottom: 15px;
      position: absolute; top: 230px; left: 320px;
      font-family: sans-serif;
      }
     .shopping,
     .food,
     .hotels,
     .entertainment,
     .guide {
      display: inline-block;
      padding-right: 90px;
      padding-left: 90px;
      }
      .shopping:hover a,
      .food:hover a,
      .hotels:hover a,
      .entertainment:hover a,
      .guide:hover a{
       color: yellow;
       -webkit-transform: scale(1.3);
       -ms-transform: scale(1.3);
       transform: scale(1.3);
       }

       .shopping a,
      .food a,
      .hotels a,
      .entertainment a,
      .guide a{
       background:red;
       display: inline-block;
      }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="navbar">
      <p class="shopping">Shopping</p>
      <p class="food">href="food.html">Food</p>
      <p class="hotels">href="hotels.html">Hotels</p>
      <p class="entertainment">href="entertainment.html">Entertainment</p>
      <p class="guide">href="guide.html">The total NOLA guide.</p>
     </div></code>```

Title: Scaling :hover effect isn't working in css on <p>

Body:
Short and simple, I'm trying to use a hover effect, and I can't seem to get it to work within this DIV at the moment and I've never came across this problem and I can't find out where I went wrong.

.navbar {
      border: solid 0px; background-color: #E6E6E6; padding-top: 15px; padding-
      bottom: 15px;
      position: absolute; top: 230px; left: 320px;
      font-family: sans-serif;
      }
     .shopping,
     .food,
     .hotels,
     .entertainment,
     .guide {
      display: inline;
      padding-right: 90px;
      padding-left: 90px;
      }
      .shopping:hover,
      .food:hover,
      .hotels:hover,
      .entertainment:hover,
      .guide:hover {
       color: yellow;
       -webkit-transform: scale(1.3);
       -ms-transform: scale(1.3);
       transform: scale(1.3);
       }

Shopping

Food

Hotels

Entertainment

The total NOLA guide.

The weird part is that the color yellow ends up being shown but the hover that I want the scaling portion is not working and I can't figure it out.

Body:
Change your code  to this.It will target the anchor tag inside the p tag.And add display:inline-block to the anchor tag for the scale to work

    .shopping:hover a,
      .food:hover a,
      .hotels:hover a,
      .entertainment:hover a,
      .guide:hover a{
       color: yellow;
       -webkit-transform: scale(1.3);
       -ms-transform: scale(1.3);
       transform: scale(1.3);
    }

.navbar {
      border: solid 0px; background-color: #E6E6E6; padding-top: 15px; padding-
      bottom: 15px;
      position: absolute; top: 230px; left: 320px;
      font-family: sans-serif;
      }
     .shopping,
     .food,
     .hotels,
     .entertainment,
     .guide {
      display: inline-block;
      padding-right: 90px;
      padding-left: 90px;
      }
      .shopping:hover a,
      .food:hover a,
      .hotels:hover a,
      .entertainment:hover a,
      .guide:hover a{
       color: yellow;
       -webkit-transform: scale(1.3);
       -ms-transform: scale(1.3);
       transform: scale(1.3);
       }

       .shopping a,
      .food a,
      .hotels a,
      .entertainment a,
      .guide a{
       background:red;
       display: inline-block;
      }

<div class="navbar">
      <p class="shopping"><a href="shopping.html">Shopping</a></p>
      <p class="food"><a href="food.html">Food</p>
      <p class="hotels"><a href="hotels.html">Hotels</p>
      <p class="entertainment"><a href="entertainment.html">Entertainment</p>
      <p class="guide"><a href="guide.html">The total NOLA guide.</p>
     </div>


问:
Files vs Database for Lua on iPhone
I have an iPhone app I'm writing which uses Lua. My question is in regards to the Lua routines. Should I keep them in an SQLite database, or a file.

I am leaning towards database because of the following perceived benefits:

1. I open the database once only, whereas with a file I have to reopen each time I want that routine. This makes it faster?

2. Easier to transfer/save the routines as they are all in one file

3. Neater file structure.

Anyone faced the same situation before?

答:
If you already use the database for something, then by all means, you can use it to store the lua procedures too.

If you have the database only for storing lua procedures, then it is probably a bit overkill.

Title: Files vs Database for Lua on iPhone


问:
How do I compute the frequency/table of categorical variables by group with R data.table?
I have the following data.table with R

```<code>library(data.table)
dt = data.table(ID = c("person1", "person1", "person1", "person2", "person2", "person2", "person2", "person2", ...), category = c("red", "red", "blue", "red", "red", "blue", "green", "green", ...))

dt
ID         category
person1    red
person1    red
person1    blue
person2    red
person2    red
person2    blue
person2    green
person2    green
person3    blue
....
</code>```

I am looking how to create a "frequency" of the categorical variables red, blue, green for each unique ID, and then expand these columns to record the counts for each. The resulting data.table would look like this:

```<code>dt
ID        red    blue    green
person1   2      1       0
person2   2      1       2
...
</code>```

I incorrectly thought the correct way to start this with data.table would be to compute the table() by group, e.g.

```<code>dt[, counts :=table(category), by=ID]
</code>```

But this appears to count the total number of categorical values by group ID. This also doesn't solve my problem of "expanding" the data.table.

What is the correct way to do this?

答:
This is done in the imperative style, there's probably a cleaner, functional way to do it.

```<code>library(data.table)
library(dtplyr)
dt = data.table(ID = c("person1", "person1", "person1", "person2", "person2", "person2", "person2", "person2"),
                category = c("red", "red", "blue", "red", "red", "blue", "green", "green"))

ids <- unique(dt$ID)
categories <- unique(dt$category)
counts <- matrix(nrow=length(ids), ncol=length(categories))
rownames(counts) <- ids
colnames(counts) <- categories

for (i in seq_along(ids)) {
  for (j in seq_along(categories)) {
    count <- dt %>%
      filter(ID == ids[i], category == categories[j]) %>%
      nrow()

    counts[i, j] <- count
  }
}
</code>```

Then:

```<code>>counts
##         red blue green
##person1   2    1     0
##person2   2    1     2
</code>```

Body:
I have the following data.table with R

library(data.table)
dt = data.table(ID = c("person1", "person1", "person1", "person2", "person2", "person2", "person2", "person2", ...), category = c("red", "red", "blue", "red", "red", "blue", "green", "green", ...))

dt
ID         category
person1    red
person1    red
person1    blue
person2    red
person2    red
person2    blue
person2    green
person2    green
person3    blue
....

I am looking how to create a "frequency" of the categorical variables red, blue, green for each unique ID, and then expand these columns to record the counts for each. The resulting data.table would look like this:

dt
ID        red    blue    green
person1   2      1       0
person2   2      1       2
...

I incorrectly thought the correct way to start this with data.table would be to compute the table() by group, e.g.

dt[, counts :=table(category), by=ID]

But this appears to count the total number of categorical values by group ID. This also doesn't solve my problem of "expanding" the data.table.

What is the correct way to do this?

Body:
This is done in the imperative style, there's probably a cleaner, functional way to do it.

library(data.table)
library(dtplyr)
dt = data.table(ID = c("person1", "person1", "person1", "person2", "person2", "person2", "person2", "person2"),
                category = c("red", "red", "blue", "red", "red", "blue", "green", "green"))

ids <- unique(dt$ID)
categories <- unique(dt$category)
counts <- matrix(nrow=length(ids), ncol=length(categories))
rownames(counts) <- ids
colnames(counts) <- categories

for (i in seq_along(ids)) {
  for (j in seq_along(categories)) {
    count <- dt %>%
      filter(ID == ids[i], category == categories[j]) %>%
      nrow()

    counts[i, j] <- count
  }
}

Then:

>counts
##         red blue green
##person1   2    1     0
##person2   2    1     2


问:
Is it possible to inline Meteor server methods definitions?
For simple client to server Meteor method calls, I sometimes find the extra abstraction to be an annoyance. Is it possible to define server methods inline? For example, I would like to replace this:

```<code>// server.js
Server.methods({ foo: console.log('bar') })
// client.js
Meteor.call('foo')
</code>```

With this:

```<code>client.js
Meteor.call(() => console.log('bar'))
</code>```

According to the documentation this is not possible, because call expects a name.

答:
You cannot define method only on client. As methods are defined on server.

https://docs.meteor.com/api/methods.html#Meteor-methods

Calling methods on the server defines functions that can be called remotely by clients.

Defining method on client (when defined on server) is used for method (UI) simulation.

Calling methods on the client defines stub functions associated with server methods of the same name...

There is a great package developed by Meteor development group for working with methods:
https://github.com/meteor/validated-method

Body:
For simple client to server Meteor method calls, I sometimes find the extra abstraction to be an annoyance. Is it possible to define server methods inline? For example, I would like to replace this:

// server.js
Server.methods({ foo: console.log('bar') })
// client.js
Meteor.call('foo')

With this:

client.js
Meteor.call(() => console.log('bar'))

According to the documentation this is not possible, because call expects a name.