This file contains hidden or 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
| def replace_ending(sentence, old, new): | |
| # Check if the old string is at the end of the sentence | |
| if sentence.endswith(old): | |
| # Using i as the slicing index, combine the part | |
| # of the sentence up to the matched string at the | |
| # end with the new string | |
| i = sentence.split() | |
| k =i[-1].replace(old,new) | |
| new_sentence=sentence[0:-len(old)]+k | |
| return new_sentence |
This file contains hidden or 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
| #report_email.py | |
| #!/usr/bin/env python3 | |
| import datetime | |
| import os | |
| from run import catalog_data | |
| from reports import generate_report | |
| from emails import generate_email, send_email | |
| def pdf_body(input_for, desc_dir): |
This file contains hidden or 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
| # reports.py | |
| #!/usr/bin/env python3 | |
| from reportlab.platypus import Paragraph, Spacer, Image, SimpleDocTemplate | |
| from reportlab.lib.styles import getSampleStyleSheet | |
| def generate_report(file, title, add_info): | |
| styles=getSampleStyleSheet() | |
| report=SimpleDocTemplate(file) | |
| report_title=Paragraph(title, styles['h1']) |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import socket | |
| import shutil | |
| import psutil | |
| import emails | |
| def check_localhost(): | |
| localhost=socket.gethostbyname('localhost') | |
| return localhost=="127.0.0.1" |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import os, requests, json | |
| def catalog_data(url, description_dir): | |
| fruit={} | |
| for item in os.listdir(description_dir): # 문제 | |
| fruit.clear() | |
| filename=os.path.join(description_dir,item) | |
| with open(filename) as f: |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import requests, os | |
| # The URL to upload the images | |
| url="http://localhost/upload/" | |
| # To get the username from environment variable | |
| USER = os.getenv('USER') | |
| # The directory which contains all the images. | |
| image_directory='/home/{}/supplier-data/images/'.format(USER) | |
| #Listing all the files in images directory | |
| files=os.listdir(image_directory) |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import os, sys | |
| from PIL import Image | |
| user = os.getenv('USER') | |
| image_directory = '/home/{}/supplier-data/images/'.format(user) | |
| for image_name in os.listdir(image_directory): | |
| if not image_name.startswith('.') and 'tiff' in image_name: | |
| image_path = image_directory + image_name |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import json | |
| import locale | |
| import sys | |
| from reports import generate as report | |
| from emails import generate as email_generate | |
| from emails import send as email_send |
This file contains hidden or 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
| def is_power_of_two(n): | |
| # Check if the number can be divided by two without a remainder | |
| while n % 2 == 0: | |
| if n<=0: | |
| return False | |
| else: | |
| n = n / 2 | |
| return True | |
| break | |
| # If after dividing by two the number is 1, it's a power of two |
This file contains hidden or 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
| #! /bin/sh | |
| # Set up a default search path | |
| PATH="/usr/bin:/bin" | |
| CURL=`which curl` | |
| if [ -z "$CURL" ]; then | |
| echo "curl not found" | |
| exit 1 | |
| fi |
NewerOlder