Ejemplo n.º 1
0
        internal string AddAzureDjangoWebRoleProcess(string webRoleName, int instances, string rootPath)
        {
            string       result;
            AzureService service = new AzureService(rootPath, null);
            RoleInfo     webRole = service.AddDjangoWebRole(webRoleName, instances);

            // let Django create it's scaffolding
            var interpPath = FindPythonInterpreterPath();

            if (interpPath != null)
            {
                string stdOut, stdErr;
                Environment.CurrentDirectory = Path.Combine(rootPath, webRole.Name);

                ProcessHelper.StartAndWaitForProcess(
                    new ProcessStartInfo(
                        Path.Combine(interpPath, PythonInterpreterExe),
                        String.Format(DjangoStartProjectCommand, webRole.Name)
                        ),
                    out stdOut,
                    out stdErr
                    );

                if (!string.IsNullOrEmpty(stdErr))
                {
                    SafeWriteObject(String.Format(Resources.UnableToCreateDjangoApp, stdErr));
                    SafeWriteObject(Resources.UnableToCreateDjangoAppFix);
                }
            }
            else
            {
                SafeWriteObject(Resources.MissingPythonPreReq);
            }

            try
            {
                service.ChangeRolePermissions(webRole);
            }
            catch (UnauthorizedAccessException)
            {
                SafeWriteObject(Resources.AddRoleMessageInsufficientPermissions);
                SafeWriteObject(Environment.NewLine);
            }

            result = string.Format(Resources.AddRoleMessageCreatePython, rootPath, webRole.Name);
            return(result);
        }
        internal string AddAzureDjangoWebRoleProcess(string webRoleName, int instances, string rootPath)
        {
            string result;
            AzureService service = new AzureService(rootPath, null);
            RoleInfo webRole = service.AddDjangoWebRole(webRoleName, instances);

            // let Django create it's scaffolding
            var interpPath = FindPythonInterpreterPath();
            if (interpPath != null)
            {
                string stdOut, stdErr;
                Environment.CurrentDirectory = Path.Combine(rootPath, webRole.Name);

                ProcessHelper.StartAndWaitForProcess(
                    new ProcessStartInfo(
                        Path.Combine(interpPath, PythonInterpreterExe),
                        String.Format(DjangoStartProjectCommand, webRole.Name)
                    ),
                    out stdOut,
                    out stdErr
                );

                if (!string.IsNullOrEmpty(stdErr))
                {
                    SafeWriteObject(String.Format(Resources.UnableToCreateDjangoApp, stdErr));
                    SafeWriteObject(Resources.UnableToCreateDjangoAppFix);
                }
            }
            else
            {
                SafeWriteObject(Resources.MissingPythonPreReq);
            }

            try
            {
                service.ChangeRolePermissions(webRole);
            }
            catch (UnauthorizedAccessException)
            {
                SafeWriteObject(Resources.AddRoleMessageInsufficientPermissions);
                SafeWriteObject(Environment.NewLine);
            }

            result = string.Format(Resources.AddRoleMessageCreatePython, rootPath, webRole.Name);
            return result;
        }