While looping to create a password protection function using Jupyter Notebook - passwords

Using Eric Pimpler's book Programing ArcGIS Pro with Python I am on Exercise 9: For and While Loops and have an issue trying to execute a code regarding a simple password and protection function.
The current modules installed are arcpy and os.
Example of code is below.
password = ' '
while password != 'password':
print("What is the password?")
password = input()
print('Yes, the password is ' + password + '. You may enter.')
What is the password?
TypeError Traceback (most recent call last)
In [229]:
Line 4: password = input()
TypeError: 'str' object is not callable
I tried to open another notebook and retype the code, it work initially, but failed after I copied and pasted the code back to my working notebook for the exercises. Sometimes I receive an * next to the cell and nothing happens I cant even cancel the kernel. Again I am running Jupyter from with ArcGIS Pro.

Related

Shell hitting Run-Time error '5' trying to call R script in Access VBA

I made a simplified version of my code that directly highlights the issue.
I have read dozens of similar issues/solution.
Part of my workflow in VBA in Microsoft Access involves calling an R script that does some logic and returns information to a table in the same database.
It was working until we moved the location of the R installation to a new drive. Changing the path to this new install location does not work. No other code is changed.
cmd = "C:\R\bin\i386\Rscript.exe C:\R\test.R"
Debug.Print cmd
Shell cmd
I get
runtime error '5'
I am using the immediate window to check the paths are correct and copying them into RUN to verify that they do work.
The above outputs:
C:\R\bin\i386\Rscript.exe C:\R\test.R
It works in RUN.
The first thing I found when searching online is to add more (") as shell can handle them weirdly:
cmd = """C:\R\bin\i386\Rscript.exe""" & " " & """C:\R\test.R"""
Or any iterations of using "s in different places, output:
"C:\R\bin\i386\Rscript.exe" "C:\R\test.R"
Same error but works in RUN. I also tried them all successfully in CMD.
It seems just Shell refuses to launch R from that path. I have moved it elsewhere on my C drive with same effect.
I cannot recreate the original R installation path as that shared drive is now completely dead.
EDIT:
I changed to using ShellExecute simply to try and make Notepad ++ open, again works in cmd.
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "C:\N\notepad++.exe", "C:\R\test_in.csv", "", "open", 1
This time I hit a "suspicious macro error" that leads me to believe that it may be an antivirus setting (macros are enabled in Access) blocking Shell from calling anything.
After days of testing I have found the solution, hopefully this can help anyone else in a similar situation. Windows Defender only blocks shell calls to non-Microsoft products, so I nested a call to PowerShell within the call to Shell:
Shell ("powershell.exe C:\R\bin\i386\Rscript.exe C:\R\test.R")
Take note you need to play around with the "s a lot ot get it working, my actual pipeline has more arguments and I had to enclose them in 5 sets of "s for it to pass through to powershell properly. IE:
Dim codePath As String: codePath = """""\\example\example"""""
Try these variations using Start or a second Command:
cmd = "Start C:\R\bin\i386\Rscript.exe C:\R\test.R"
or:
cmd = "cmd /c ""C:\R\bin\i386\Rscript.exe C:\R\test.R"""

Error Printing: No application is associated with the specified file for this operation

I have a VB WinForms app that prints PDFs using Process.Start, and it has been working fine for ages on Windows 10. Today I go to use it and get the following error message:
"No application is associated with the specified file for this operation"
Nothing has changed to cause this, I have not changed PDF Viewer or uninstalled anything. I can open a PDF by double clicking on it no problems.
I wrote a small console app to replicate the issue and prove this had nothing to do with the WinForms app:
Sub Main()
Dim pi As New Diagnostics.ProcessStartInfo
Dim url As String = "C:\PathToPDF\.pdf"
pi.FileName = url
pi.Verb = "PrintTo"
pi.CreateNoWindow = True
pi.Arguments = """Microsoft Print to PDF"""
pi.UseShellExecute = True
Console.WriteLine(url)
Diagnostics.Process.Start(pi)
Console.ReadKey()
End Sub
The above program replicates the error. I have verified that the file exists and is accessible and tried it with double slashes and single slashes, they give the same error:
"No application is associated with the specified file for this operation".
The same application is working fine on other PCs in the office.
Has anyone else had this happen, and if so how did they fix it?
My PDF viewer is PDFXChange Viewer, and it has been working fine PDFs printed using this method for years. I have not updated the program, and it says in the about page that the last installed updated was in 2016.
Regards.
If I am right, I had the same issue. Maybe you can try it in a slightly other way. I have this in my application and it works fine:
Dim myp As New Process
myp.StartInfo.FileName = filename 'Full path to pdf
myp.Start()

How do I run edge on login in Group policy &/Or login script

I am trying to run edge on all client machines when they log in. This is easily done with IE as you just set iexplore.exe in the Startup section of Group Policy but not having much luck with Edge.
I have tried creating a .bat / .cmd and trying to call it
Code:
#echo off
start microsoft-edge:https://google.ie/
I know the above works as Edge opens up when i double click the cmd/bat
I am trying to call this from within a login.vbs script but am having no joy, any ideas? or alternatively if anyone has been able to get this working in Group policy? Thanks.
VBS Code:
Function Edge()
dim shell
set shell=createobject("wscript.shell")
shell.run "\\ipbdc3\SYSVOL\ipbdomain.local\scripts\edge.cmd"
set shell=nothing
End Function

VBA (Word) - can i see if application is already open

I've been having experiencing an issue with Word VBA where, if the Application is already open, it would just crash and doesn't do any further steps. I've been surfing the Net trying to figure this out, but no luck. The error appears at the o.Workbooks.Open line:
Dim o as Excel.Application
o.Workbooks.Open (ActiveDocument.Path + "\Data.xlsm")
Error message is
c:\fol\data.xlsm is already open or doesn't exist
It basically saves the data that was entered in Word text boxes. Note: All code afterwards works fine, this is the line where it breaks. I've tried using On Error that it would just stop, but it doesn't seem to work :/
Any ideas?

SAS EG asking for credentials "randomly" when called from VB

I have the following function in an Excel sheet module, which sends SQL queries to SAS:
Function run_query(query)
Dim app ' application
Dim project ' Project object
Dim sasProgram ' Code object (SAS program)
Set app = CreateObject("SASEGObjectModel.Application.5.1")
Set project = app.New
Set sasProgram = project.CodeCollection.Add
sasProgram.Text = "PROC SQL;" + query + " QUIT;"
sasProgram.Run
app.Quit
End Function
It sometimes works like a charm, and most often doesn't, as it asks for my credentials (triggered by command sasProgram.Run as it's where the debugger stops), I didn't find a way to make the error, or success, reproducible.
I've set my credentials persistence to Persist for user but I still have issues.
I've also tried to set my Autentification to None (attempt anonymous connection) and Windows integrated (Uses your current windows account) and none of them changed the situation.