-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a cronjob creation script, fixed typo in setup.py, moved example config to root of project. Signed-off-by: Sebastian Fricke <[email protected]>
- Loading branch information
Showing
4 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
import math | ||
import crontab | ||
|
||
def enter_interval(): | ||
interval = '' | ||
print("Enter the time interval in min.") | ||
while not interval: | ||
try: | ||
interval = int(input("->")) | ||
except ValueError: | ||
print("Enter a number.") | ||
return interval | ||
|
||
def create_cronjob(sync): | ||
user = os.environ['USER'] | ||
cron = crontab.CronTab(user=user) | ||
job = [] | ||
interval = enter_interval() | ||
for s in sync: | ||
command = str(f'python3 -m fb_feed_sync {s}') | ||
job.append( | ||
cron.new(command=command).minute.every(interval)) | ||
cron.write() | ||
print("Written to crontab, check with 'crontab -e'") | ||
|
||
def main(): | ||
print("Cronjob setup for the facebook-feed-sync:\n\n") | ||
print("Specify a single time interval for ALL synchronization types?") | ||
all_option = input("(j/N)") | ||
if all_option.lower() == 'j': | ||
create_cronjob(sync=['inventory', 'price', 'text']) | ||
elif not all_option or all_option.lower() == 'n': | ||
print("Cronjob for inventory synchronization:") | ||
create_cronjob(sync=['inventory']) | ||
print("Cronjob for price synchronization:") | ||
create_cronjob(sync=['price']) | ||
print("Cronjob for text synchronization:") | ||
create_cronjob(sync=['text']) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[General] | ||
inventory_plenty_url=https://panasiam.plentymarkets-cloud01.com/export/... | ||
attr_plenty_url=https://panasiam.plentymarkets-cloud01.com/export/... | ||
price_plenty_url=https://panasiam.plentymarkets-cloud01.com/export/... | ||
text_plenty_url=https://panasiam.plentymarkets-cloud01.com/export/... | ||
image_plenty_url=https://panasiam.plentymarkets-cloud01.com/export/... | ||
plenty_warehouse= | ||
google_sheet_id= | ||
google_sheet_rows=1991 | ||
log-path= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters