pyfly-mcooperba 0.0.1
Package to allow python interaction with FLY
Requires Python: ~=3.6

# pyfly
Package to allow python interaction with FLY. 

## Functions

### SendCmd(cmd, program="")
Sends a command `cmd` to the specified program `program`. If the program is not specified, it will attempt to send the command to the foreground window.
* Returns **True** if it doesn't detect an issue. This doesn't guarantee the command was sucessfully sent.
* Returns **False** if there is an issue detected.

### SendFly(cmd, timeout=10)
Sends command `cmd` to FLY. Has a default timeout of 10 seconds. Will attempt to send the entry up to 5 times in case the command isn't correctly sent first time.
**IMPORTANT** Requires logging to be enabled in FLY.
* Returns **True** if there is a response from FLY detected before the time out (excluding a `CHECK FORMAT` response).
* Returns **False** if there is no response from FLY within the timeout limit.

### ReadFly(truncate=False)
Reads the entire log file generated by FLY. Will archive the log file if `truncate = True`.
* Returns the content of the FLY log file.

### MaxValueFromDict(dictionary)
Finds max value in dictionary.
* Returns `[key, value]` pair for the first instance of the max value within the dictionary.

### GetNextQueue()
Specifically designed for COVID voucher processing. Truncates the FLY log file, then does QT to find the queue with the most PNRs.
* Returns `[string, int]` containing [queue number, number of PNRs on that queue]
* Returns **None** If all queues are empty.

### GetQueueResult(q)
Specifically designed for COVID voucher processing. Decodes the inputted queue number to the processing result:
* Returns a string containing the Queue's result/reason, or None if it cannot match:
  * 51C0: "GARYJNR"
  * 52C0: "PROCESS"
  * 53C0: "TRADE"
  * 53C1: "OPTIONTOWN"
  * 53C2: "COMMAIR_SUNAIR"
  * 54C0: "RFD_EXC"
  * 55C0: "MID_TVL"
  * 56C0: "NOTELIG"
  * 58C0: "BAH"
  * 63C0: "GROUP"
  * 62C0: "PROCESS"
  * 64C0: "RFD_EXC"
  * 65C0: "MID_TVL"
  * 66C0: "NOTELIG"
  * 66C1: "NOSHOW"
  * 68C0: "BAH"

### GetMsgQueue(q):
Specifically designed for COVID voucher processing. Gets the 15Below queue used for messaging each voucher result.
* Returns the 15Below queue, or None if it cannot match:
  * 52C0: "90C0" *No longer downloaded*
  * 53C0: "91C0" *No longer downloaded*
  * 53C1: "91C0" *No longer downloaded*
  * 53C2: "91C0"
  * 54C0: ""
  * 55C0: "92C0" *No longer downloaded*
  * 56C0: "93C0" *No longer downloaded*
  * 58C0: ""
  * 63C0: "91C1" *No longer downloaded*
  * 62C0: "90C0" *No longer downloaded*
  * 64C0: ""
  * 65C0: "92C0" *No longer downloaded*
  * 66C0: "93C0" *No longer downloaded*
  * 66C1: ""
  * 68C0: "" *No longer downloaded*


### CountOnQueue(Q_input)
Counts how many PNRs are on the inputted queue.
* Returns integer value of number of PNRs on specified queue.

### NeedMD()
Checks to see if the last FLY response is scrollable (can do `MD` to see more).
* Returns **True** if scrollable
* Returns **False** if not scrollable

### NeedQVMD()
Checks to see if the last FLY Queue View (`QV`) response needs a `QVMD` request to view more PNRs.
* Returns **True** if scrollable
* Returns **False** if not scrollable

### QB(from_queue, to_queue, num_of_PNRs=99999)
Performs a `QB` entry in FLY to move up to 999 PNRs from one queue to another. If `num_of_PNRs` is not specified, all PNRs will be moved.
* Returns the number of PNRs on the target queue (`to_queue`) after performing the move.
  *  If the destination queue already has PNRs on it, the user is prompted to continue. If they choose "no" then -1 is returned.

### OneQueueToTwo(from_queue, to_queue1, to_queue2, num_of_PNRs=99999)
Moves PNRS from one queue to two others. It does this by choreographing copies of up to 999 PNRs from the input queue to the first destination queue, then moving those same PNRs to the second destination queue, then repeats until the input queue is empty.
* Returns the minumum number of PNRs on the target queues after performing the copy.
  * If the destination queue already has PNRs on it, the user is prompted to continue. If they choose "no" then -1 is returned.

### QV(Q):
Performs a Queue View (QV) in FLY for the specified queue. Will automatically scroll and QVMD to get the full queue contents.
WARNING this truncates the log file to start with.
* This function does not return anything.

### CleanQueueView(log_content)
To use, first run QV, then ReadFly, then finally CleanQueueView to extract the PNRs
* Returns a **set** of PNRs (without dupes) from the result of a QueueView `QV`.

### WriteFile(filename, content)
Outputs a CSV file containing the provided `content` (no headers) with the provided `filename` with a timestamp appended.
* Returns the full path of the newly created file.

### Write15BelowFile(filename, df)
Outputs a CSV file in the format required for uploading to 15Below to send manual notifications.
The input pandas DataFrame `df` should have columns: FULLNAME, MSG, EMAIL & PNR.
* Returns the full path of the newly created file.

### SQLtoDF(sql)
Takes an SQL SELECT statement and returns the results in a pandas DataFrame.
* Returns DataFrame with SQL results.

### DoInsert(sql, data)
Performs SQL INSERT statement (using `?` as a placeholder for data) and executes on mass with provided data.
* This function does not return anything.

### DoSQL(sql)
Performs provided SQL.
* This function does not return anything.

### AppendFiles(files, have_headers, delete_when_done = False)
Joins files together.
`files` should be a list of files.
`have_headers` should be `True` or `False` to indicated if the files have a header row / line.
If `delete_when_done` is `True` then all input files will be deleted on completion.
* Returns the full path of the newly created file.