Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2012-04-27 17:43:29 +02:00
4 changed files with 37 additions and 14 deletions
+4 -1
View File
@@ -1,4 +1,7 @@
#!/usr/bin/env python
import sys
base_path = sys.argv.pop()
sys.path.insert(0, base_path)
from fix_getpass import fixGetpass
import os
from django.core.management import execute_manager
@@ -14,5 +17,5 @@ if not manage_file:
if __name__ == "__main__":
fixGetpass()
run_module(manage_file, None, '__main__')
run_module(manage_file, None, '__main__', True)
+9 -7
View File
@@ -11,11 +11,13 @@ if not manage_file:
settings_file = os.getenv('DJANGO_SETTINGS_MODULE')
if not settings_file:
settings_file = 'settings'
settings_file = 'settings'
proj_name = sys.argv[-1]
base_path = sys.argv.pop()
proj_name = base_path.split("/")[-1]
sys.path.insert(0, base_path)
os.environ.setdefault('DJANGO_SETTINGS_MODULE',proj_name+".settings")
from django.core import management
from django.core.management.commands.test import Command
from django.conf import settings
@@ -37,9 +39,9 @@ class PycharmTestCommand(Command):
# handle south migration in tests
management.get_commands()
if hasattr(settings, "SOUTH_TESTS_MIGRATE") and not settings.SOUTH_TESTS_MIGRATE:
# point at the core syncdb command when creating tests
# tests should always be up to date with the most recent model structure
management._commands['syncdb'] = 'django.core'
# point at the core syncdb command when creating tests
# tests should always be up to date with the most recent model structure
management._commands['syncdb'] = 'django.core'
else:
try:
from south.management.commands import MigrateAndSyncCommand
@@ -97,7 +99,7 @@ if __name__ == "__main__":
subcommand = 'help' # Display help if no arguments were given.
if subcommand == 'test':
utility = PycharmTestManagementUtility(sys.argv[:-1])
utility = PycharmTestManagementUtility(sys.argv)
else:
utility = ManagementUtility()
utility.execute()
@@ -306,13 +306,21 @@ public abstract class PythonCommandLineState extends CommandLineState {
private static void addToPythonPath(VirtualFile file, Collection<String> pathList) {
if (file.getFileSystem() instanceof JarFileSystem) {
VirtualFile realFile = JarFileSystem.getInstance().getVirtualFileForJar(file);
final VirtualFile realFile = JarFileSystem.getInstance().getVirtualFileForJar(file);
if (realFile != null) {
pathList.add(FileUtil.toSystemDependentName(realFile.getPath()));
addIfNeeded(realFile, pathList);
}
}
else {
pathList.add(FileUtil.toSystemDependentName(file.getPath()));
addIfNeeded(file, pathList);
}
}
private static void addIfNeeded(@NotNull final VirtualFile file, @NotNull final Collection<String> pathList) {
final Set<String> vals = Sets.newHashSet(pathList);
final String filePath = FileUtil.toSystemDependentName(file.getPath());
if (!vals.contains(filePath)) {
pathList.add(filePath);
}
}
@@ -323,9 +331,14 @@ public abstract class PythonCommandLineState extends CommandLineState {
@NotNull
public static Collection<String> collectPythonPath(@Nullable Module module) {
return collectPythonPath(module, true);
}
@NotNull
public static Collection<String> collectPythonPath(@Nullable Module module, final boolean addProjectRoots) {
Collection<String> pythonPathList = Sets.newLinkedHashSet();
pythonPathList.add(PythonHelpersLocator.getHelpersRoot().getPath());
if (module != null) {
if (module != null && addProjectRoots) {
addLibrariesFromModule(module, pythonPathList);
Set<Module> dependencies = new HashSet<Module>();
ModuleUtil.getDependencies(module, dependencies);
@@ -142,8 +142,13 @@ public class PythonTask {
}
protected List<String> setupPythonPath() {
List<String> pythonPath = Lists.newArrayList(PythonCommandLineState.getAddedPaths(mySdk));
pythonPath.addAll(PythonCommandLineState.collectPythonPath(myModule));
return setupPythonPath(true);
}
protected List<String> setupPythonPath(final boolean addProjectRoot) {
final List<String> pythonPath = Lists.newArrayList(PythonCommandLineState.getAddedPaths(mySdk));
if (addProjectRoot)
pythonPath.addAll(PythonCommandLineState.collectPythonPath(myModule));
return pythonPath;
}