Alright, I have two folders that need to be in sync, but certain files need to be ignored before the first upload.
To make sense of what I mean lets say for example I have a folder called src and another folder called dest.
src contains settings.properties, some python code, and a template properties file.
dest contains the same settings.properties, same python code but the template properties file is populate during the sync process (done by a script that wraps the protocol)
Now, if I decide to modify the python code in dest, the python code should be updated in src folder, but the new template.properties which is populated should be ignored.
I tried using excludes and includes but I read that you can't use both because "includes takes precedence"
Using Windows, and I am currently using a python script that formats the paths to the default "/cygdrive/C/" then I populate the properties file, then I run rsync
Related
I have a large number of auto generated code files that are identifiable by the having _pb2 in the file name.
When I search using PyCharm CTRL+Shift+F I can use a file mask. I would like for instance to find all Python files *.py that do not have _pb2 in their name. Is there a way to achieve that?
You can include and exclude files and directories by creating a Custom Scope that filters using a combination of filename wildcards.
Ctrl+Shift+F to open "Find in Path".
Create a new Custom Scope following steps 2-4 in the screenshot.
Enter the pattern, for your specification it would be file[Project_Name]:*.py&&!file:*_pb2*
Afterwards the search results are restricted to within the Custom Scope.
Source at JetBrains official site: "Scope configuration controls"
Selected Files (3)
Menu Selection Send To ----
Result, Program will run for how many files are selected for this example it is 3
I have made an addition to windows registry and made a right click menu option for files. I attached a program to the option that will attach the file to an email and send me the file. When I select multiple files it will create multiple emails. What I want is for all the files to attach to a single email.
What I've tried:
1. I have tried a for loop in python script for sys.argv[n] / Didn't work because the program will run for each individual file selected
The issue is with Windows Explorer. You need to tell it you can handle multiple names. Have you registered your handler with an "open" verb? If you register it with the "OpenWithList" verb, then Explorer should send the whole list to one executable. I'm looking up the exact setting now.
Yes, HKEY_CURRENT_USER\Software\Classes\.mkv\OpenWithList\xxx.py.
Create a batch file.
insert #echo off cls command_path/command.exe %* into the batch file
Go to command location in windows registry and change the default value to the newly created batch file.
Continue if you don't want the command.exe location to be a part of the files sent
Create an array named files. ex. files = []
create a for loop to append to files ex. for i in sys.argv: if i != sys.argv[0]: files.append(i)
The files value will be inserted accordingly to the part of the api structure that handles attachments. Make sure to put it in as *files if you're not putting it into a list then files will work just fine.
(For those who are not in the know. The * is a spread operator. More examples on spread operators can be found easily by looking up spread operator.)
The script needs to read from a .txt file with a list of items and based off that list, it creates a directory for each item. So just a simple with open() statement and then os.mkdir()..
The client will add account names to the txt file when they get new accounts, the program will create new directories for those new accounts. Files that are then placed in each directory for those accounts will get pandas stuff done to them and moved to an archive folder along with logging the events.
Since the program will be used by non-programmers, I'm using Pyinstaller.
When I go through the process, including the --add-file attribute, run the program, it says the txt file doesn't exist. I think I have an idea how to fix that but when I got the os.mkdir and with open statements to work by separating them out, it created them in the home folder and not the program folder. Path issue? And I only see documentation on how to include data files but not how to include changeable files.
Pardon if I couldn't synthesize precisely my problem with my title, however I guess that by explaning it, things will get more clear.
My problem is the following: I am sending a file containing two scripts to a client, one of them generates a set of articial data, in the form of a dataframe, and the other to import and process that data. So, I want my exported csv to be on the same folder as the script that will generate it, however I don't want to write the usual path manually, as I would write on my PC, because I am sending the file to someone else.
df.to_csv(r'Path where you want to store the exported CSV file\File_Name.csv')
So, lets say that the scripts are in a folder named "A", is there somehow to setting the generated CSV to be saved on this specific folder, a parent folder, as well as being imported by the second script, without having to write the whole folder path that I would normally do if I were on my PC?
I expect something like this:
df.to_csv(r'...\A\File_Name.csv')
You can import os and then use
os.getcwd()
It will give you the path that the script is running from, from there you can
access any directory from that path so:
df.to_csv(os.getcwd() + r'\A\File_Name.csv')
You can use dot as relative path. ./ means current directory, ../ means parent directory.
df.to_csv('../File_Name.csv') means save the csv file to parent directory.
df.to_csv('./A/File_Name.csv') means save the csv file to subfolder A.
By the way, dot relative path and the other answer os.getcwd(), work with where the script runing, not where the script exists.
like this python script/data.py, ./ means the directory of script directory, not the directory of data.py, same as os
I want to change the default directory listing of the pythonwebkit(the one imported from gi.repository) for an application I am working on. Is there any function/script in webkit that does the job?
EDIT
The code for styling the default directory listing is in the file net/base/dir_header.html and ends up in chrome.pak and chrome_100_percent.pak.
The python module data_pack.py can work with these files.
If you want to filter certain file types from the list, you can probably do that in addRow()
You will have to use os.chdir() to change the current directory for the whole process. AFAIK, WebKit doesn't keep an internal environment for things like the current folder.