Skip to content

Commit

Permalink
Version 1.1: Cronjob creation
Browse files Browse the repository at this point in the history
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
initBasti committed Jul 1, 2020
1 parent 52640b1 commit 7a2453c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,6 @@ data/.credentials.json
data/config.ini
data/token.pickle
/Tests
/backup_data
prepare_data_folder_for_prod.sh
prepare_data_folder_for_dist.sh
42 changes: 42 additions & 0 deletions cronsetup.py
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()
10 changes: 10 additions & 0 deletions example_config.ini
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=
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def run(self):

setup(
name='fb_feed_sync',
version='1.0',
version='1.1',
description='Synchronize data to a google sheet from a plenty export',
license='GPLv3',
long_description=long_description,
Expand All @@ -48,6 +48,6 @@ def run(self):
],
entry_points={'script':['fb_feed_sync = fb_feed_sync.__main__:main']},
data_files=[('data', ['data/.credentials.json', 'data/config.ini'])],
include_pacakage_data = True,
include_package_data = True,
cmdclass={'install':OverrideInstall}
)

0 comments on commit 7a2453c

Please sign in to comment.