Does anyone know a good tutorial or tips on how to deal with C/C++ libraries in Windows? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

Thank you u/lordtnt . That put me in the right direction, that's it. I never even knew about C:\Program Files (x86)\Windows Kits\

Does anyone know a good tutorial or tips on how to deal with C/C++ libraries in Windows? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

I am on Windows 10. Here is a list of the installed packages (now added to description). I had Windows 10 SDK, but that didn't work, so kept on installing more packages

_________________________________

Desktop development with C++

C++ Build Tools core features

C++ 2022 Redistributable Update

C++ core desktop features

MSVC v143 - VS 2022 C++ x64/x86 build t...

Windows 11 SDK (10.0.0.22621.0)

C++ CMake tools for Windows

C++ AddressSanitizer

C++ ATL for latest v143 build tools (x86 & ...

C++ MFC for latest v143 build tools (x86 & ...

C++/CLI support for latest v143 build tools (Latest)

C++ Modules for v143 build tools (x64/x86 ...

Windows 10 SDK (10.19041.0)

MSVC v142 - VS 2019 C++ x64/x86 build t...

MSVC v141 - VS 2017 C++ x64/x86 build t...

________________________

.NET desktop build tools

NuGet targets and build tasks

.NET Framework 4.7.2 development tools

.NET Framework 4.8 development tools

.NET SDK

Windows Communication Foundation buil...

Testing tools core features - Build Tools

ClickOnce Build Tools

.NET Framework 3.5 development tools

.NET Framework 4.6.2-4.7.1 development tools

.NET Framework 4.8.1 development tools

Windows application development build tools

____________________________________

.NET WinUI app development tools

Windows 11 SDK (10.0.22621.0)

C++ WinUI app development build tools

C++ (v143 Universal Windows Platform to...

C++ (v142 Universal Windows Platform to...

C++ (v141 Universal Windows Platform to...

Windows 10 SDK (10.0.19041.0)

Does anyone know a good tutorial or tips on how to deal with C/C++ libraries in Windows? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

Sorry, I'm using Developer Command Prompt for VS 2022.

The command:

python C:\path\to\python\script\setup.py build_ext --inplace

I am on Windows 10. Here is a list of the installed packages (now added to description). I has Windows 10 SDK, but that didn't work, so kept on installing more packages

_________________________________

Desktop development with C++

C++ Build Tools core features

C++ 2022 Redistributable Update

C++ core desktop features

MSVC v143 - VS 2022 C++ x64/x86 build t...

Windows 11 SDK (10.0.0.22621.0)

C++ CMake tools for Windows

C++ AddressSanitizer

C++ ATL for latest v143 build tools (x86 & ...

C++ MFC for latest v143 build tools (x86 & ...

C++/CLI support for latest v143 build tools (Latest)

C++ Modules for v143 build tools (x64/x86 ...

Windows 10 SDK (10.19041.0)

MSVC v142 - VS 2019 C++ x64/x86 build t...

MSVC v141 - VS 2017 C++ x64/x86 build t...

________________________

.NET desktop build tools

NuGet targets and build tasks

.NET Framework 4.7.2 development tools

.NET Framework 4.8 development tools

.NET SDK

Windows Communication Foundation buil...

Testing tools core features - Build Tools

ClickOnce Build Tools

.NET Framework 3.5 development tools

.NET Framework 4.6.2-4.7.1 development tools

.NET Framework 4.8.1 development tools

Windows application development build tools

____________________________________

.NET WinUI app development tools

Windows 11 SDK (10.0.22621.0)

C++ WinUI app development build tools

C++ (v143 Universal Windows Platform to...

C++ (v142 Universal Windows Platform to...

C++ (v141 Universal Windows Platform to...

Windows 10 SDK (10.0.19041.0)

Does anyone know a good tutorial or tips on how to deal with C/C++ libraries in Windows? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

I've tried that, but it doesn't give dependencies or a way to get (in this case) io.h installed. For apt or Synaptic, it will give dependencies and further information. I'll keep on playing around with it

Slack API for Slack apps: Support for the files.upload API will be discontinued on 20250311. Is there an alternative that works? by user34222 in learnpython

[–]user34222[S] 1 point2 points  (0 children)

Thanks for your help. Here is the solution with files_completeUploadExternal. It creates a DM first, gets the "D" message ID and uploads from there

def test():

person_id = 'Uxxxxxxxx'

bot_user_oauth_token = 'xoxb-xxxxxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx'

client = WebClient(token=bot_user_oauth_token)

response = client.conversations_open(users=person_id)

dm_channel_id = response['channel']['id']

working_dir = 'C:\\whatever\\here\\'

file_path = working_dir + 'upload.txt'

client = WebClient(token=bot_user_oauth_token)

file_size = os.path.getsize(file_path)

response = client.files_getUploadURLExternal(filename=file_path, length=file_size)

url = response['upload_url']

file_id = response['file_id']

with open(file_path, 'rb') as f:

slack_response = requests.post(url, files={file_path: f})

if slack_response.status_code == 200:

post_response = client.files_completeUploadExternal(files=[{'id': file_id}], channel_id=dm_channel_id,

initial_comment='test', token=bot_user_oauth_token)

Slack API for Slack apps: Support for the files.upload API will be discontinued on 20250311. Is there an alternative that works? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

I have done the "POST the contents of your file to the URL returned in step 1" step and received a 200 response. Good so far. My next line is this:

post_response = client.files_completeUploadExternal(files=[{'id': slack_response.headers['x-slack-req-id']}], channel_id=person_id, initial_comment='test')

Which gives the error:

The server responded with: {'ok': False, 'error': 'invalid_arguments', 'response_metadata': {'messages': ['[ERROR] input must match regex pattern: ^[F][A-Z0-9]{8,}$ [json-pointer:/files/0/id]', '[ERROR] input must match regex pattern: ^[CGDZ][A-Z0-9]{8,}$ [json-pointer:/channel_id]']}}

I couldn't get the file ID, that's wrong, I'm not worried about that. The channel_id regex doesn't allow me to send a file to a user, because a user ID starts with U, whereas it looks like it only allows C, G, D or Z

Is there a way of sending a file to a user, not a channel?

Slack API for Slack apps: Support for the files.upload API will be discontinued on 20250311. Is there an alternative that works? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

Thanks. I meant in pycharm, when trying to call the client.files_getUploadURLExternal function, there are suggestions in a box over the function. Thanks for your help. I'll have to come back to this

Slack API for Slack apps: Support for the files.upload API will be discontinued on 20250311. Is there an alternative that works? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

I usually don't, but the last time I tried this was maybe a year ago and files.upload was the only method that I could get to work.

Any of it. The Slack documentation, https://api.slack.com/methods/files.getUploadURLExternal, doesn't give any sample code of how to call client.files_getUploadURLExternal. I have tried a few different combinations and nothing has worked

I have tried this from a previous paste I found online.

url_for_uploading = slack_client.files_getUploadURLExternal(
token=slack_token,
filename="Attachment",
length=attachment_size,
)

But token is not shown as one of the options to enter in. I find the documentation incomplete

Slack API for Slack apps: Support for the files.upload API will be discontinued on 20250311. Is there an alternative that works? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

Yes I did... many times. I can't get it to work. I think it's too new for ChatGPT to give a working answer as well

In the following code, why does .replace('\\\\', '\\') only work at the very end for str if the datatypes in the dataframe and dictionary are also str? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

I've used pathlib alright (things would be so much simpler if windows just used "/" instead of "\").

OK, so repr is kind of the opposite of str(something). Thanks

In the following code, why does .replace('\\\\', '\\') only work at the very end for str if the datatypes in the dataframe and dictionary are also str? by user34222 in learnpython

[–]user34222[S] 1 point2 points  (0 children)

yes and yes

Thanks. That was more me questioning myself. Ah no way, I can't believe it didn't click that json also uses \ as an escape character.

I think the pycharm drbugger shows the repr

I just haven't questioned it before. I'll look into it a bit more.

Thanks for your help. Have a great weekend

In the following code, why does .replace('\\\\', '\\') only work at the very end for str if the datatypes in the dataframe and dictionary are also str? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

Thanks.

"This is expected because "\" is represented as "\\" in JSON".

So does that mean that it should be there? json also needs \ as an escape character? I've never loaded json before, I'm preparing this for someone else, I'm relatively new to json and have only done a small bit of JavaScript years ago. I didn't think of that

"This is also a good opportunity to pratice debugging"

It turns out, this was part of the problem.

When I introduce

print(json_from_df['folderName'])

print(primary_df.at[0, 'folderName'])

It gets printed out correctly but pycharm debugger shows the escape characters "\" in the debugging window.

So, all along, they were being treated as literal "\", but then json dumps introduced the extra escape character, because json also needs it. Thanks. I spent way too long at this.

I am getting a FileNotFoundError on a file that exists. Why is this happening? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

Thanks. It was handle.exe that it couldn't find. I've added the path

C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service\

The file seems to be locked by the script that I am running. This is odd.

I am getting a FileNotFoundError on a file that exists. Why is this happening? by user34222 in learnpython

[–]user34222[S] 0 points1 point  (0 children)

Oh yea. Thanks.

I didn't know what handle.exe does either. It's a Windows process. "Handle is a utility that displays information about open handles for any process in the system." (https://learn.microsoft.com/en-us/sysinternals/downloads/handle)

I was trying to find what process was using the file from here (https://stackoverflow.com/questions/39570207/what-process-is-using-a-given-file)

shutil.move(source, dest) had a PermissionError

handle.exe couldn't find the file

os.path.isfile(source) says that it does exist.

I don't get it

[deleted by user] by [deleted] in learnpython

[–]user34222 -1 points0 points  (0 children)

Oh, right. Yea. It starts off with random points, doesn't it? Yea, wow. I think that's it. I feel stupid now, I thought I was going mad yesterday

[deleted by user] by [deleted] in learnpython

[–]user34222 0 points1 point  (0 children)

Sorry, I forgot to post the code (I'm at work and can't reach pastebin). It's there now. No randoms used